<template>
  <div class="main">
    <p  class="main_text">配件库存管理</p>
    <!-- ############################################## 表单 ############################################## -->
    <div class="content p20 cyr-flex">
      <el-tabs v-model="activeName">
        <!-- ********** 溯源件 ********** -->
        <el-tab-pane name="first">
          <template #label>
            <span>溯源件</span>
          </template>
          <!-- ############################################## 查询 ############################################## -->
          <div class="top">
            <el-form :model="searchFittings" label-position="right" class="df fww">
              <el-form-item v-if="cmopany == 0" label="公司名称：" style="width: 300px;margin-right: 10px">
                <el-select v-model="searchFittings.companyNode" filterable placeholder="公司名称">
                  <el-option v-for="item in companyList" :key="item.id" :label="item.companyName" :value="item.node" />
                </el-select>
              </el-form-item>
              <el-form-item label="配件名称：" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.fittingName" placeholder="配件名称：" />
              </el-form-item>
              <el-form-item label="配件类型：" style="width: 300px;margin-right: 10px">
                <el-select v-model="searchFittings.typeId" placeholder="请选择配件类型" filterable>
                  <el-option v-for="item in shopGoodsList" :key="item.type_id" :label="item.type_name"
                    :value="item.type_id" />
                </el-select>
              </el-form-item>
              <el-form-item label="配件描述：" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.description" placeholder="配件描述" />
              </el-form-item>
              <el-form-item label="品牌：" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.brand" placeholder="品牌" />
              </el-form-item>
              <el-form-item label="车系：" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.series" placeholder="车系" />
              </el-form-item>
              <el-form-item label="车型：" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.modelName" placeholder="车型" />
              </el-form-item>
              <el-form-item label="仓库名称：" style="width: 300px;margin-right: 10px">
                <el-select v-model="searchFittings.warehouseName" placeholder="仓库名称" filterable>
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="拆解组" style="width: 300px;margin-right: 10px">
                <el-input v-model="searchFittings.dismantleTeamName" placeholder="拆解组" />
              </el-form-item>
              <el-form-item style="width: 300px;margin-right: 10px">
                <el-button type="primary" @click="searchFittingsBtn">查询</el-button>
                <el-button type="primary" plain @click="rescFittings">重置</el-button>
              </el-form-item>
            </el-form>
          </div>
          <el-divider />
          <div class="mb20">
            <el-button type="primary" @click="InDialogVisible = true" v-if="roleList.write">入库</el-button>
            <el-tooltip class="box-item" effect="dark" content="请先查询你要出库的仓库，再选择出库配件进行批量操作" placement="top-start">
              <el-button type="primary" plain @click="outbound" v-if="roleList.write">批量出库</el-button>
            </el-tooltip>
            <el-tooltip class="box-item" effect="dark" content="请先查询你要调拨的仓库，再选择调拨配件进行批量操作" placement="top-start">
              <el-button type="primary" plain @click="transferSave" v-if="roleList.write">批量调拨</el-button>
            </el-tooltip>
            <el-button type="primary" plain @click="exportExcelFitting" v-if="roleList.write">导出数据</el-button>
          </div>
          <div class="cyr-flex-box">
          <el-table @selection-change="handleSelectionChange" :data="tableData"
             :header-cell-style="{ background: '#f0f6fe' }" :show-overflow-tooltip="true" v-adaptive
            border>
            <el-table-column type="selection" width="50" />
            <el-table-column label="配件编号" prop="fittingId" show-overflow-tooltip />
            <el-table-column label="配件名称" prop="fittingName" show-overflow-tooltip>
              <template #default="props">
                <el-text tag='span' style='cursor: pointer;' @click="details(props.row)">{{ props.row.fittingName
                  }}</el-text>
              </template>
            </el-table-column>
            <el-table-column label="配件类型" prop="typename" show-overflow-tooltip />
            <el-table-column label="品牌" prop="brand" show-overflow-tooltip />
            <el-table-column label="车系" prop="series" show-overflow-tooltip />
            <el-table-column label="车型" prop="modelName" show-overflow-tooltip />
            <el-table-column label="配件描述" prop="fittingDescription" show-overflow-tooltip />
            <el-table-column label="仓库名称" prop="warehouseName" show-overflow-tooltip />
            <el-table-column label="仓储位置" prop="warehouseArea" show-overflow-tooltip />
            <el-table-column label="入库时间" prop="created" show-overflow-tooltip />
            <el-table-column label="拆解组" prop="dismantleTeamName" show-overflow-tooltip />
            <el-table-column label="oe码" prop="oeCode" show-overflow-tooltip />
            <el-table-column fixed="right" label="操作" width="140">
              <template #default="props">
                <el-button size="small" link type="primary" @click="details(props.row)"
                  v-if="roleList.read">详情</el-button>
                <el-button size="small" link type="primary" @click="fittingsOutBoundDialog(props.row)"
                  v-if="roleList.write">出库</el-button>
                <el-button size="small" link type="primary" @click="fittingTransferDialog(props.row)"
                  v-if="roleList.write">调拨</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <smartPager v-model:current-page="currentPage" v-model:page-size="pageSize" :total="Number(total)"
            @change="handleCurrentChange" />
          </div>
          <!-- ############################################## 蒙层---溯源件 ############################################## -->
          <!-- ****************************** 详情 ****************************** -->
          <el-drawer v-model="drawer" size="50%" style="background: #f5f9ff">
            <div class="drawer_top p20">
              <div class="df aic">
                <div>
                  <h1 style="font-weight: 700; font-size: 1.125rem; color: #3d3d3d">
                    {{ editformData.fittingName }}
                  </h1>
                  <span style="color: #9e9e9e; font-size: 0.75rem">配件：{{ editformData.fittingId }}</span>
                </div>
              </div>
              <el-divider style="margin: 0.625rem 0" />
              <el-form :model="editformData" label-width="10rem" label-position="left">
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715329549706" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="9333" width="14" height="14">
                        <path
                          d="M965.818182 209.454545h-651.636364a34.909091 34.909091 0 0 1 0-69.818181h651.636364a34.909091 34.909091 0 0 1 0 69.818181zM965.818182 535.272727h-651.636364a34.909091 34.909091 0 0 1 0-69.818182h651.636364a34.909091 34.909091 0 0 1 0 69.818182zM965.818182 861.090909h-651.636364a34.909091 34.909091 0 0 1 0-69.818182h651.636364a34.909091 34.909091 0 0 1 0 69.818182zM150.341818 52.363636v215.970909h-44.218182V101.934545a77.265455 77.265455 0 0 1-23.272727 12.8 97.047273 97.047273 0 0 1-26.065454 6.981819V84.014545a191.767273 191.767273 0 0 0 65.396363-31.650909zM97.28 566.690909H186.181818v36.770909H46.545455v-15.825454A69.818182 69.818182 0 0 1 52.596364 558.545455 88.901818 88.901818 0 0 1 69.818182 532.247273a192.465455 192.465455 0 0 1 32.814545-27.694546 130.56 130.56 0 0 0 28.625455-26.996363A42.821818 42.821818 0 0 0 139.636364 452.421818c0-19.083636-10.472727-28.392727-31.185455-28.392727a78.429091 78.429091 0 0 0-52.130909 21.643636v-39.098182a110.312727 110.312727 0 0 1 62.138182-17.92 73.076364 73.076364 0 0 1 50.036363 16.058182A56.32 56.32 0 0 1 186.181818 449.396364a73.541818 73.541818 0 0 1-5.12 28.392727 86.574545 86.574545 0 0 1-15.592727 23.272727 200.610909 200.610909 0 0 1-32.349091 26.996364 176.64 176.64 0 0 0-28.625455 23.272727 24.436364 24.436364 0 0 0-7.214545 15.36zM53.527273 892.509091a78.661818 78.661818 0 0 0 49.338182 15.127273 46.545455 46.545455 0 0 0 28.392727-7.912728 26.298182 26.298182 0 0 0 10.472727-23.272727 25.832727 25.832727 0 0 0-12.567273-23.272727 64.698182 64.698182 0 0 0-34.909091-7.912727h-18.850909v-32.116364H93.090909q42.589091 0 42.589091-28.625455c0-17.92-10.938182-26.996364-32.581818-26.996363a69.818182 69.818182 0 0 0-41.192727 13.963636v-36.538182a110.778182 110.778182 0 0 1 51.2-11.170909 81.454545 81.454545 0 0 1 48.872727 13.730909 46.545455 46.545455 0 0 1 18.618182 38.4 49.338182 49.338182 0 0 1-42.123637 52.130909 55.854545 55.854545 0 0 1 35.374546 16.058182A46.545455 46.545455 0 0 1 186.181818 878.312727a56.32 56.32 0 0 1-22.109091 46.545455 94.487273 94.487273 0 0 1-58.647272 16.989091A109.381818 109.381818 0 0 1 53.527273 930.909091z"
                          p-id="9334" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">配件编号：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.fittingId }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715332621539" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="30501" width="14" height="14">
                        <path
                          d="M329.142857 0H124.342857C58.514286 0 0 58.514286 0 124.342857v204.8c0 65.828571 58.514286 124.342857 124.342857 124.342857h204.8c65.828571 0 124.342857-58.514286 124.342857-124.342857V124.342857C453.485714 51.2 402.285714 0 329.142857 0zM131.657143 102.4h204.8c14.628571 0 21.942857 7.314286 21.942857 21.942857v204.8c0 14.628571-7.314286 21.942857-21.942857 21.942857H131.657143c-14.628571 0-21.942857-7.314286-21.942857-21.942857V124.342857c0-14.628571 7.314286-21.942857 21.942857-21.942857z"
                          p-id="30502" fill="#b6b6b6"></path>
                        <path
                          d="M577.828571 51.2h380.342858c36.571429 0 65.828571 29.257143 65.828571 65.828571s-29.257143 65.828571-65.828571 65.828572H577.828571c-36.571429 0-65.828571-29.257143-65.828571-65.828572 0-43.885714 29.257143-65.828571 65.828571-65.828571zM577.828571 636.342857h380.342858c36.571429 0 65.828571 29.257143 65.828571 65.828572s-29.257143 65.828571-65.828571 65.828571H577.828571c-36.571429 0-65.828571-29.257143-65.828571-65.828571s29.257143-65.828571 65.828571-65.828572zM577.828571 256h380.342858c36.571429 0 65.828571 29.257143 65.828571 65.828571s-29.257143 65.828571-65.828571 65.828572H577.828571c-36.571429 0-65.828571-29.257143-65.828571-65.828572s29.257143-65.828571 65.828571-65.828571zM577.828571 841.142857h380.342858c36.571429 0 65.828571 29.257143 65.828571 65.828572s-29.257143 65.828571-65.828571 65.828571H577.828571c-36.571429 0-65.828571-29.257143-65.828571-65.828571s29.257143-65.828571 65.828571-65.828572z"
                          p-id="30503" fill="#b6b6b6"></path>
                        <path
                          d="M329.142857 570.514286H124.342857C58.514286 570.514286 0 629.028571 0 694.857143v204.8c0 65.828571 58.514286 124.342857 124.342857 124.342857h204.8c65.828571 0 124.342857-58.514286 124.342857-124.342857V694.857143c0-65.828571-51.2-124.342857-124.342857-124.342857zM131.657143 672.914286h204.8c14.628571 0 21.942857 7.314286 21.942857 21.942857v204.8c0 14.628571-7.314286 21.942857-21.942857 21.942857H131.657143c-14.628571 0-21.942857-7.314286-21.942857-21.942857V694.857143c0-7.314286 7.314286-21.942857 21.942857-21.942857z"
                          p-id="30504" fill="#b6b6b6"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">配件名称：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.fittingName }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715332744263" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="33565" width="14" height="14">
                        <path
                          d="M512 11.410286A500.589714 500.589714 0 1 0 1012.589714 512 500.882286 500.882286 0 0 0 512 11.410286z m0 942.665143A442.075429 442.075429 0 1 1 954.075429 512 442.660571 442.660571 0 0 1 512 954.075429z"
                          p-id="33566" fill="#9e9e9e"></path>
                        <path
                          d="M743.424 380.342857a165.595429 165.595429 0 0 0-165.302857-165.595428h-263.314286a32.768 32.768 0 0 0-34.230857 32.475428v529.261714c0 18.724571 8.192 34.230857 26.624 34.230858s21.942857-16.384 21.942857-34.816v-231.424h228.205714c2.633143 5.266286 5.851429 11.117714 8.484572 16.676571l122.88 225.28a29.257143 29.257143 0 0 0 39.789714 14.043429c17.846857-9.069714 9.947429-33.938286 0-49.737143l-119.954286-208.896A165.010286 165.010286 0 0 0 743.424 380.342857z m-155.355429 108.251429h-261.266285V260.096h261.266285a114.102857 114.102857 0 0 1 0 227.913143z"
                          p-id="33567" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">品牌：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.brand }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715332806541" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="34619" width="14" height="14">
                        <path
                          d="M749.754 128.585c38.998 0 70.198 15.599 93.597 42.898 27.298 23.399 42.898 54.597 42.898 93.596 0 38.998-15.6 70.198-42.898 97.497-23.4 23.399-54.598 38.998-93.597 38.998v-42.898c27.299 0 50.698-7.8 66.298-27.299 15.6-15.599 27.299-38.998 27.299-66.298 0-27.298-11.7-50.697-27.3-66.298-15.598-15.599-38.997-27.298-66.297-27.298v-42.898z m0 495.28c38.998 0 70.198 15.6 93.597 38.999 27.298 23.399 42.898 58.497 42.898 93.597 0 38.998-15.6 74.097-42.898 97.496-23.4 23.4-54.598 38.998-93.597 38.998v-38.998c27.299 0 50.698-11.7 66.298-27.299 15.6-19.499 27.299-42.898 27.299-70.197 0-23.4-11.7-46.798-27.3-66.298-15.598-15.6-38.997-27.299-66.297-27.299v-38.998zM445.566 405.475L621.06 304.077c-3.9-11.699-7.8-23.398-7.8-38.998 0-38.998 15.6-70.197 38.998-97.496 27.3-23.4 58.499-38.998 97.497-38.998v42.898c-27.299 0-50.698 11.699-66.298 27.298-19.5 15.6-27.299 38.999-27.299 66.298 0 11.7 0 19.5 3.9 31.199v3.9l3.9 3.9v3.9c7.8 15.599 23.399 31.198 38.998 38.998 3.9 3.9 7.8 3.9 11.7 3.9 11.699 7.799 23.398 7.799 35.098 7.799v42.898c-19.5 0-35.098-3.9-50.698-11.7-3.9 0-11.7-3.9-15.599-7.8-15.6-7.799-31.199-23.398-42.898-38.997l-171.594 97.496v7.8c11.7 23.399 15.6 46.798 15.6 70.198 0 31.198-3.9 54.597-15.6 81.897l163.793 89.697c3.9-11.7 11.7-19.5 19.5-27.299 27.298-23.399 58.498-38.998 97.496-38.998v38.998c-27.299 0-50.698 11.7-66.298 27.299-19.5 19.499-27.299 42.898-27.299 66.298v3.9c0 23.398 7.8 46.797 27.299 66.297 15.6 15.6 38.998 27.3 66.298 27.3v38.997c-38.998 0-70.198-15.599-97.497-38.998-23.399-23.399-38.998-58.498-38.998-93.596v-3.9c0-7.8 3.9-19.5 3.9-27.299L445.565 627.767l-11.7 11.7c-31.198 35.097-74.097 54.597-124.795 54.597v-42.898c38.998 0 70.198-15.6 97.497-35.099 23.399-23.399 38.998-58.498 38.998-97.496 0-19.5-3.9-35.099-11.7-54.598-3.9-3.9-3.9-3.9-3.9-7.8-3.9-3.9-3.9-7.8-7.799-11.699-11.7-15.6-23.399-27.299-38.998-38.998-3.9 0-3.9-3.9-7.8-3.9-19.499-11.7-42.898-15.6-66.298-15.6v-42.9c31.199 0 58.499 7.8 85.797 23.4 3.9 0 7.8 3.9 11.7 7.8 15.599 7.799 27.298 19.498 38.999 31.198zM309.07 694.064c-46.798 0-93.597-19.5-124.795-54.598-31.199-27.299-50.698-70.198-50.698-120.895 0-46.798 19.5-89.697 50.698-124.796 31.198-31.198 77.997-50.697 124.795-50.697v42.898c-38.998 0-70.198 15.599-97.496 38.998-23.4 23.399-38.999 58.497-38.999 93.597 0 38.998 15.6 74.097 38.999 97.496 27.298 19.5 58.498 35.099 97.496 35.099v42.898z"
                          fill="#9e9e9e" p-id="34620"></path>
                      </svg>&nbsp;

                      <p style="color: #9e9e9e">车系：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.series }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715332899526" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="37498" width="14" height="14">
                        <path
                          d="M1011.2 578.6c-4.2-57.8-39.2-109-91.4-134l-45.4-220.4c-17.2-83.6-98.6-151.6-181.6-151.6H331.2c-82.8 0-164.4 68-181.6 151.6L104.2 444.6c-52.4 25-87.2 76.2-91.4 134l-10.4 142.8c-4.4 61.8 28.8 119 83.2 143 13.8 51.2 58.8 86.6 110.6 86.6 47 0 89.6-29.8 106.6-74.6h418.6c17.2 44.8 59.6 74.6 106.6 74.6 51.8 0 96.8-35.6 110.6-86.6 54.4-24 87.6-81.2 83.2-143l-10.6-142.8z m-112.6 222.2c-15.4 3.8-26.8 17.6-27.6 34-1.2 24-20 42.8-43 42.8-22.4 0-40.8-17.6-43-41-1.6-18.8-17.2-33.6-35.6-33.6H274.6c-18.6 0-34 14.4-35.6 33.6-2 23.4-20.4 41-42.8 41-23 0-42-18.8-43.2-42.8-0.8-16.2-12.2-30.2-27.6-34-33-7.8-54.2-38.2-51.6-73.8l10.4-142.8c2.6-35.2 28.2-67 62.6-77.6 13.6-4.2 23.6-16.4 25.2-31 0.2-1.6 0.2-3.4 0.4-5v-1.4-1.2l47-228.2c10.4-50.6 61.6-93.2 111.6-93.2h361.6c50 0 101 42.8 111.6 93.2L851.2 468c0 0.4 0 1 0.2 1.4v0.8c0.2 1.8 0.2 3.8 0.4 5.6 1.6 14.6 11.6 26.8 25.4 31 34.2 10.6 60 42.4 62.4 77.6l10.4 142.8c2.8 35.4-18.4 65.8-51.4 73.6z"
                          p-id="37499" fill="#9e9e9e"></path>
                        <path
                          d="M787.2 582.4c-19.6 0-39 8.2-52.8 22.6-13.8 14.4-21.8 34.2-21.8 54.4 0 20.2 8 40 21.8 54.4 14 14.4 33.2 22.6 52.8 22.6 19.6 0 39-8.2 52.8-22.6 13.8-14.4 21.8-34.2 21.8-54.4 0-20.2-8-40-21.8-54.4-14-14.4-33.2-22.6-52.8-22.6zM237 582.4c-19.6 0-39 8.2-52.8 22.6-13.8 14.4-21.8 34.2-21.8 54.4 0 20.2 8 40 21.8 54.4 14 14.4 33.2 22.6 52.8 22.6 19.6 0 39-8.2 52.8-22.6 13.8-14.4 21.8-34.2 21.8-54.4 0-20.2-8-40-21.8-54.4-14-14.4-33.2-22.6-52.8-22.6zM274.2 483H750c12.8 0 24.2-5 31.2-13.6 7.4-8.8 10.4-20.8 8.6-34-0.2-0.8-0.4-1.8-0.6-2.6l-37.4-167.4c-5.2-29-32.4-52.6-61-52.6H333.2c-28.4 0-55.8 23.6-61 52.4l-37.4 167.6c-0.2 0.8-0.4 1.6-0.4 2.2v0.4c-2 12.8 1 25 8.2 33.4 7.4 9.2 18.6 14.2 31.6 14.2z m66.8-196.6h342l27.4 123H313.6l27.4-123z"
                          p-id="37500" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">车型：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.modelName }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715333024860" class="icon" viewBox="0 0 1171 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="38921" width="14" height="14">
                        <path
                          d="M1065.919657 408.40895a34.308991 34.308991 0 0 0-34.308991 32.329626l-12.535977 515.954441h-50.803698l9.896824-478.346508a33.649203 33.649203 0 0 0-33.649203-34.308991H227.328744a33.649203 33.649203 0 0 0-33.649203 34.308991l9.896824 478.346508H152.772667l-12.535977-515.954441a34.308991 34.308991 0 0 0-33.649203-32.329626 32.989414 32.989414 0 0 0-32.989415 34.308991L86.13405 989.682432a33.649203 33.649203 0 0 0 33.649203 32.989414h118.102103a36.948144 36.948144 0 0 0 27.05132-8.577248 36.288356 36.288356 0 0 0 6.597883-24.412166L264.936676 511.995711h648.571887l-13.195766 477.686721a33.649203 33.649203 0 0 0 9.896824 24.412166 31.669838 31.669838 0 0 0 23.752379 9.896825h118.102103a32.989414 32.989414 0 0 0 33.649203-32.989415l13.195766-548.284067a32.989414 32.989414 0 0 0-32.989415-34.308991z"
                          p-id="38922" fill="#9e9e9e"></path>
                        <path
                          d="M800.684766 961.311535H370.502802a29.030685 29.030685 0 0 0 0 58.06137h430.181964a29.030685 29.030685 0 1 0 0-58.06137zM827.736086 804.281923H344.111271a33.649203 33.649203 0 0 0-33.649203 33.649203 33.649203 33.649203 0 0 0 33.649203 33.649202h483.624815a33.649203 33.649203 0 1 0 0-65.978829zM370.502802 714.550716h430.181964a29.030685 29.030685 0 1 0 0-58.06137H370.502802a29.030685 29.030685 0 0 0 0 58.06137zM1154.991076 347.708428L585.593784 0 16.85628 347.708428A32.989414 32.989414 0 0 0 6.299667 395.872973a33.649203 33.649203 0 0 0 46.18518 11.216401L585.593784 79.174595 1122.66145 405.110009a35.628568 35.628568 0 0 0 17.814284 4.618518 32.329626 32.329626 0 0 0 25.071955-13.855554 33.649203 33.649203 0 0 0-10.556613-48.164545z"
                          p-id="38923" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">仓库名称：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.warehouseName }}</el-text>
                  <!-- <el-input v-model="editformData.name" /> -->
                </el-form-item>
                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715333057934" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="40328" width="14" height="14">
                        <path
                          d="M1017.041254 531.456L523.473254 26.112c-3.072-3.072-7.68-5.12-12.288-5.12-4.608 0-8.704 2.048-12.288 5.12L4.817254 533.504c-4.608 5.12-6.144 12.288-3.584 18.432 2.56 6.144 8.704 10.24 15.872 10.24h91.648v440.32h79.872V482.304h-22.016l344.576-353.792 345.6 353.792H839.889254v520.192h79.872v-440.32h87.552c9.216 0 16.896-7.68 16.896-16.896 0-5.632-3.072-10.752-7.168-13.824z"
                          p-id="40329" fill="#9e9e9e"></path>
                        <path
                          d="M725.201254 602.112c-10.752-26.112-26.112-49.664-46.08-69.632-19.968-19.968-43.52-35.328-69.632-46.08-25.088-10.24-51.712-15.36-78.848-15.36S476.369254 476.16 451.281254 486.4c-26.112 10.752-49.664 26.112-69.632 46.08-19.968 19.968-35.328 43.52-46.08 69.632-10.24 25.088-15.36 51.712-15.36 78.848s5.12 53.76 15.36 78.848c10.752 26.112 26.112 49.664 46.08 69.632l82.944 82.944 32.256-32.256-82.944-82.944c-64-64-64-167.936 0-231.936 30.72-30.72 72.192-48.128 116.224-48.128s84.992 16.896 116.224 48.128c64 64 64 167.936 0 231.936l-148.48 148.48 32.256 32.256 148.48-148.48c19.968-19.968 35.328-43.52 46.08-69.632 10.24-25.088 15.36-51.712 15.36-78.848s-5.12-53.76-14.848-78.848z"
                          p-id="40330" fill="#9e9e9e"></path>
                        <path
                          d="M623.313254 672.768c0-52.224-42.496-94.208-94.208-94.208s-94.208 42.496-94.208 94.208 42.496 94.208 94.208 94.208c52.224 0 94.208-41.984 94.208-94.208z m-94.208 48.64c-26.624 0-48.64-21.504-48.64-48.64 0-26.624 21.504-48.64 48.64-48.64 26.624 0 48.64 21.504 48.64 48.64 0 26.624-22.016 48.64-48.64 48.64z"
                          p-id="40331" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">仓储位置：</p>
                    </div>
                  </template>
                  <el-text>{{ editformData.warehouseArea }}</el-text>
                </el-form-item>

                <el-form-item>
                  <template #label>
                    <div class="df aic">
                      <svg t="1715333108071" class="icon" viewBox="0 0 1024 1024" version="1.1"
                        xmlns="http://www.w3.org/2000/svg" p-id="42262" width="14" height="14">
                        <path
                          d="M843.875 135.125h-90V90.125c0-11.25-16.875-28.125-33.75-28.125s-28.125 11.25-28.125 28.125v39.375H360.125V90.125c0-11.25-11.25-28.125-28.125-28.125s-28.125 16.875-28.125 28.125v39.375H180.125C129.5 135.125 90.125 174.5 90.125 219.5v652.5c0 50.625 39.375 90 90 90h663.75c50.625 0 90-39.375 90-90V219.5c0-45-39.375-84.375-90-84.375z m28.125 736.875c0 16.875-11.25 28.125-28.125 28.125H180.125c-16.875 0-28.125-11.25-28.125-28.125V219.5c0-16.875 11.25-28.125 28.125-28.125h118.125v5.625c5.625 16.875 16.875 33.75 33.75 33.75s28.125-11.25 28.125-28.125v-11.25h331.875v5.625c0 16.875 11.25 28.125 28.125 28.125s28.125-11.25 28.125-28.125v-5.625h90c16.875 0 28.125 11.25 28.125 28.125v652.5z"
                          p-id="42263" fill="#9e9e9e"></path>
                        <path
                          d="M753.875 337.625H270.125c-16.875 0-28.125 11.25-28.125 28.125s11.25 33.75 28.125 33.75h483.75c16.875 0 28.125-11.25 28.125-28.125s-11.25-33.75-28.125-33.75zM753.875 517.625H270.125c-16.875 0-28.125 11.25-28.125 28.125s11.25 28.125 28.125 28.125h483.75c16.875 0 28.125-11.25 28.125-28.125s-11.25-28.125-28.125-28.125zM512 697.625H270.125c-16.875 0-28.125 11.25-28.125 28.125s11.25 28.125 28.125 28.125H512c16.875 0 28.125-11.25 28.125-28.125s-11.25-28.125-28.125-28.125z"
                          p-id="42264" fill="#9e9e9e"></path>
                      </svg>&nbsp;
                      <p style="color: #9e9e9e">配件描述：</p>
                    </div>
                  </template>
                  <p style="width: 90%; line-height: 1.5rem">
                    {{ editformData.fittingDescription }}
                  </p>
                </el-form-item>
              </el-form>
            </div>
          </el-drawer>
          <!-- ****************************** 添加入库单 ****************************** -->
          <el-drawer v-model="InDialogVisible" size="50%" style="background: #f5f9ff" v-if="InDialogVisible"
            @close="closeInDialogVisible">
            <template #header>
              <h4 style="font-weight: 700; font-size: 1.125rem; color: #3d3d3d">
                添加入库单
              </h4>
            </template>
            <div class="drawer_top p20">
              <el-form ref="editformDataRef" :rules="editformDataRefRules" :model="editformData" label-position="top"
                class="df fww jcsb">
                <!-- <el-form-item label="入库类型：" style="width: 48%" prop="status">
                  <el-select v-model="editformData.status" placeholder="入库类型：">
                    <el-option label="采购入库" value="0" />
                    <el-option label="调拨入库" value="1" />
                    <el-option label="手动录入" value="2" />
                  </el-select>
                </el-form-item> -->
                <el-form-item label="入库仓库：" style="width: 48%" prop="warehouseId">
                  <el-select v-model="editformData.warehouseId" placeholder="入库仓库：" @change="changeWareHouse1">
                    <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                      :value="item.warehouseId" />
                  </el-select>
                </el-form-item>
              </el-form>
            </div>
            <div class="drawer_top p20 mt20">
              <el-button type="primary" @click="Addproducta(editformDataRef)">添加产品</el-button>
              <el-button type="primary" plain>导入产品</el-button>
              <!-- <el-button plain>批量移除</el-button> -->
              <el-table :data="AddProductTableData" style="width: 100%" class="mt20"
                :header-cell-style="{ background: '#f5f7fa' }" border max-height="470">
                <!-- <el-table-column type="selection" width="50" /> -->
                <el-table-column label="配件名称" prop="fittingName" />
                <el-table-column label="配件描述" prop="fittingDescription" />
                <el-table-column label="配件类型" prop="typeName" />
                <el-table-column label="品牌" prop="brand" />
                <el-table-column label="车系" prop="series" />
                <el-table-column label="车型" prop="modelName" />
                <el-table-column label="仓库位置" prop="storageLocationTab" />
                <el-table-column label="OE码" prop="oeCode" />
                <el-table-column fixed="right" label="操作">
                  <template #default="props">
                    <el-button size="small" link type="primary"
                      @click="removeAddProductTableData(props.$index)">移除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>

            <template #footer>
              <div class="drawer_bottom df jcsb aic">
                <div>
                  <!-- <el-button type="primary" link>
                    <el-icon class="icondy">
                      <Wallet /> </el-icon
                    >&nbsp;打印此入库单</el-button
                  > -->
                </div>
                <div>
                  <el-button @click="InDialogVisible = false">取消</el-button>
                  <el-button type="primary" @click="submitSingle" :loading="loading">提交入库单</el-button>
                  <!-- <el-button type="primary" @click="InDialogVisible = false">提交并审核</el-button> -->
                </div>
              </div>
            </template>
            <!-- ***************** 配件入库-添加产品 *****************-->
            <el-dialog class="dialog" v-model="AddDialogVisible" title="添加产品" width="40%" align-center
              @click="visible = false" @close="closeAddDialogVisible">
              <template #header>
                <div class="df aic">
                  <el-icon style="color: #fff" size="20">
                    <Edit />
                  </el-icon>&nbsp;
                  <p style="color: #fff">添加产品</p>
                </div>
              </template>
              <el-form :model="AddProductFormData" ref="ruleFormRef" :rules="rules" class="df fdc aic"
                label-width="100px" @click="handleClick">
                <el-form-item label="配件名称：" style="width: 70%" prop="fittingName">
                  <el-input v-model="AddProductFormData.fittingName" placeholder="请输入配件名称" @click="visible = false" />
                </el-form-item>
                <el-form-item label="配件描述：" style="width: 70%" prop="fittingDescription">
                  <el-input v-model="AddProductFormData.fittingDescription" placeholder="请输入配件描述"
                    @click="visible = false" />
                </el-form-item>
                <el-form-item label="配件类型：" style="width: 70%" prop="typeName">
                  <el-select v-model="AddProductFormData.typeName" placeholder="请选择配件类型" filterable allow-create
                    default-first-option @click="visible = false">
                    <el-option v-for="item in shopGoodsList" :key="item.type_id" :label="item.type_name"
                      :value="item.type_name" />
                  </el-select>
                </el-form-item>
                <!-- 品牌车型车系 -->
                <el-form-item label="品牌:" prop="brand" style="width: 70%">
                  <div style="position: relative;width: 100%">
                    <div @click.stop="brandSelect">
                      <el-input v-model="AddProductFormData.brand" class="form_input" placeholder="请选择品牌"
                        style="width: 100%" @blur="brandClick(AddProductFormData.brand)" @input="searchBrand" />
                    </div>
                    <div v-if="visible" class="menu" style="
                          position: absolute;
                          z-index: 90;
                          background: #fff;
                          box-shadow: #e4e7ed 0px 0px 10px;
                          padding: 5px;
                          top: 32px;
                          width:100%;
                          border-radius: 5px;
                        ">
                      <div class="city_menu_container" @scroll="onScroll">
                        <div class="area" v-for="(item, index) in brandList" :key="index" style="width: 90%">
                          <div class="itemTit" ref="item.letter" :id="item.letter"
                            style="background: #e0e0e0; padding: 5px">
                            {{ item.letter }}
                          </div>
                          <div class="item action"
                            :class="{ active_brand: brandIndex === newIndex && wortIndex === index, }"
                            v-for="(list, newIndex) in item.data" :key="newIndex" @click="chose(list, index, newIndex)">
                            {{ list }}
                          </div>
                        </div>
                      </div>
                      <ul class="city_list_container">
                        <li v-for="(item, index) in wortList" :key="index" @click.stop="jump(index)"
                          style="width: 20px; height: 20px">
                          {{ item }}
                        </li>
                      </ul>
                    </div>
                  </div>
                </el-form-item>
                <el-form-item label="车系:" prop="series" style="width: 70%">
                  <div style="position: relative;width: 100%">
                    <div @click.stop="SeriesSelect">
                      <el-input v-model="AddProductFormData.series" class="form_input" placeholder="请选择车系"
                        style="width: 100%" @input="searchSerise" />
                    </div>
                    <div v-if="visibleSerise" class="menu" style="
                          position: absolute;
                          z-index: 90;
                          background: #fff;
                          box-shadow: #e4e7ed 0px 0px 10px;
                          padding: 5px;
                          top: 32px;
                          width:100%;
                          border-radius: 5px;
                          height: 300px;
                        ">
                      <div class="city_menu_container" @scroll="onScroll">
                        <div class="area" v-for="(item, index) in carType" :key="index" style="width: 90%">
                          <div class="itemTit" ref="item.letter" :id="item.letter" style="padding: 5px"
                            @click="carTypeSelect(item)">
                            {{ item.seriesName }}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-form-item>
                <el-form-item label="车型:" prop="modelName" style="width: 70%">
                  <div style="position: relative;width: 100%">
                    <div @click.stop="modelSelect">
                      <el-input v-model="AddProductFormData.modelName" class="form_input" placeholder="请选择车型"
                        style="width: 100%" @input="searchModel" />
                    </div>
                    <div v-if="visibleModel" class="menu" style="
                          position: absolute;
                          z-index: 90;
                          background: #fff;
                          box-shadow: #e4e7ed 0px 0px 10px;
                          padding: 5px;
                          top: 32px;
                          width:100%;
                          border-radius: 5px;
                          height: 300px;
                        ">
                      <div class="city_menu_container" @scroll="onScroll">
                        <div class="area" v-for="(item, index) in carSeriesList" :key="index" style="width: 90%">
                          <div class="itemTit" ref="item.letter" :id="item.letter" style="padding: 5px"
                            @click="ModelTypeSelect(item)">
                            {{ item.modelName }}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-form-item>
                <el-form-item label="仓储位置：" style="width: 70%" prop="storageLocation">
                  <el-cascader v-model="AddProductFormData.storageLocation" placeholder="存储位置" :options="options1"
                    filterable style="width: 100%" @change="asdasdada" />
                </el-form-item>
                <el-form-item label="OE码" style="width: 70%">
                  <el-input v-model="AddProductFormData.oeCode" placeholder="选填" @click="visible = false" />
                </el-form-item>
              </el-form>
              <template #footer>
                <span class="dialog-footer">
                  <el-button type="primary" plain @click="AddDialogVisible = false">取消</el-button>
                  <el-button type="primary" @click="AddProductData(ruleFormRef)">添加产品</el-button>
                </span>
              </template>
            </el-dialog>
          </el-drawer>
          <!-- ****************************** 溯源件批量出库 ****************************** -->
          <el-drawer v-model="outDialogVisible" size="50%" style="background: #f5f9ff" @close="closeOutBound">
            <template #header>
              <h4 style="font-weight: 700; font-size: 1.125rem; color: #3d3d3d">
                添加出库单
              </h4>
            </template>
            <div class="drawer_top p20">
              <el-form v-model="outBoundTableData" label-position="top" class="df fww jcsb">
                <el-form-item label="出库类型：" style="width: 48%">
                  <el-input value="销售出库" placeholder="" disabled />
                </el-form-item>
                <!-- <el-form-item label="出库类型：" style="width: 48%">
                  <el-select v-model="outBoundTableData.status" placeholder="出库类型：">
                    <el-option label="销售出库" value="0" />
                    <el-option label="调拨出库" value="1" />
                    <el-option label="自用出库" value="2" />
                  </el-select>
                </el-form-item> -->
                <el-form-item label="出库仓库：" style="width: 48%">
                  <el-select v-model="outBoundTableData.warehouseId" placeholder="出库仓库：" disabled>
                    <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                      :value="item.warehouseId" />
                  </el-select>
                </el-form-item>
                <!-- <el-form-item label="价格：" style="width: 48%;">
                                    <el-input v-model="outBoundTableData.price" placeholder="Please input">
                                        <template #prepend>￥</template>
                                    </el-input>
                                </el-form-item> -->
                <!-- <el-form-item label="备注：" style="width:  48%;">
                                    <el-input v-model="outBoundTableData.remark" placeholder="" />
                                </el-form-item> -->
              </el-form>
            </div>
            <div class="drawer_top p20 mt20">
              <el-table @selection-change="handleSelectionChange" :data="removeOutBoundTableDataslect"
                style="width: 100%" max-height="440" :header-cell-style="{ background: '#f0f6fe' }">
                <!-- <el-table-column type="selection" width="50" /> -->
                <el-table-column label="配件编号" prop="fittingId" show-overflow-tooltip />
                <el-table-column label="配件名称" prop="fittingName" show-overflow-tooltip />
                <el-table-column label="配件描述" prop="fittingDescription" show-overflow-tooltip />
                <!-- <el-table-column label="配件类型" prop="typeId" show-overflow-tooltip /> -->
                <el-table-column label="品牌" prop="brand" show-overflow-tooltip />
                <el-table-column label="车系" prop="series" show-overflow-tooltip />
                <el-table-column label="型号" prop="model.value" show-overflow-tooltip />
                <el-table-column label="仓库名称" prop="warehouseName" show-overflow-tooltip />
                <el-table-column label="仓库编码" prop="storeId" show-overflow-tooltip />
              </el-table>
            </div>

            <template #footer>
              <div class="drawer_bottom df jcsb aic">
                <!-- <div>
                  <el-button type="primary" link>
                    <el-icon class="icondy">
                      <Wallet /> </el-icon
                    >&nbsp;打印此出库单</el-button
                  >
                </div> -->
                <div>
                  <el-button @click="outDialogVisible = false">取消</el-button>
                  <el-button type="primary" @click="submitOutbound" :loading="loading">提交出库单</el-button>
                  <!-- <el-button type="primary">提交并审核</el-button> -->
                </div>
              </div>
            </template>
          </el-drawer>
          <!-- ****************************** 溯源件出库 ****************************** -->
          <el-dialog v-model="fittingOutBoundDialogVisible" width="40%" align-center
            @close="closeFittingOutBoundDialogVisible">
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">溯源件出库</p>
              </div>
            </template>
            <el-form :model="fittingOutBoundData" label-position="top" class="df fww jcsb">
              <el-form-item label="出库仓库：" style="width: 48%">
                <el-input v-model="fittingOutBoundData.warehouseName" disabled />
              </el-form-item>
              <el-form-item label="出库区域：" style="width: 48%">
                <el-input v-model="fittingOutBoundData.warehouseArea" disabled />
              </el-form-item>
              <el-form-item label="配件名称：" style="width: 48%">
                <el-input v-model="fittingOutBoundData.fittingName" disabled />
              </el-form-item>
              <el-form-item label="配件类型：" style="width: 48%">
                <el-input v-model="fittingOutBoundData.typeName" disabled />
              </el-form-item>
              <el-form-item label="车型：" style="width: 48%">
                <el-input type="textarea" v-model="fittingOutBoundData.modelName" disabled />
              </el-form-item>
              <el-form-item label="车系：" style="width: 48%">
                <el-input v-model="fittingOutBoundData.series" disabled />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="fittingOutBoundDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="fittingsOutBound"> 出库 </el-button>
              </span>
            </template>
          </el-dialog>
          <!-- ****************************** 溯源件批量调拨 ****************************** -->
          <el-drawer v-model="diaoDialogVisible" size="50%" style="background: #f5f9ff" @close="closeTransfer">
            <template #header>
              <h4 style="font-weight: 700; font-size: 1.125rem; color: #3d3d3d">
                添加调拨单
              </h4>
            </template>
            <div class="drawer_top p20">
              <el-form v-model="transferData" label-position="top" class="df fww jcsb">
                <el-form-item label="调出仓库：" style="width: 48%">
                  <el-select v-model="transferData.outWarehouseId" placeholder="调出仓库：" disabled>
                    <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                      :value="item.warehouseId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="调入仓库：" style="width: 48%">
                  <el-select v-model="transferData.inWarehouseId" placeholder="调入仓库：" @change="changetransfer">
                    <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                      :value="item.warehouseId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="调入区域：" style="width: 48%">
                  <el-cascader v-model="transferData.transferInArea" placeholder="存储位置" :options="optionsAlot"
                    filterable style="width: 100%" @focus="changeAreaAlot" />
                </el-form-item>
              </el-form>
            </div>
            <div class="drawer_top p20 mt20">
              <el-table :data="removeAllotTableDataslect" style="width: 100%" max-height="440"
                :header-cell-style="{ background: '#f0f6fe' }">
                <el-table-column label="配件编号" prop="fittingId" show-overflow-tooltip />
                <el-table-column label="配件名称" prop="fittingName" show-overflow-tooltip />
                <el-table-column label="配件描述" prop="fittingDescription" show-overflow-tooltip />
                <el-table-column label="配件类型" prop="typeName" show-overflow-tooltip />
                <el-table-column label="品牌" prop="brand" show-overflow-tooltip />
                <el-table-column label="车系" prop="series" show-overflow-tooltip />
                <el-table-column label="型号" prop="modelName" show-overflow-tooltip />
                <el-table-column label="仓库名称" prop="warehouseName" show-overflow-tooltip />
              </el-table>
            </div>

            <template #footer>
              <div class="drawer_bottom df jcsb aic">
                <!-- <div>
                  <el-button type="primary" link>
                    <el-icon class="icondy">
                      <Wallet />
                    </el-icon>&nbsp;打印此出库单</el-button>
                </div> -->
                <div>
                  <el-button @click="diaoDialogVisible = false">取消</el-button>
                  <el-button type="primary" @click="transfer" :loading="loading">提交调拨单</el-button>
                  <!-- <el-button type="primary">提交并审核</el-button> -->
                </div>
              </div>
            </template>
          </el-drawer>
          <!-- ****************************** 溯源件调拨 ****************************** -->
          <el-dialog v-model="fittingTransferDialogVisible" width="40%" align-center>
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">溯源件调拨</p>
              </div>
            </template>
            <el-form :model="fittingTransferData" ref="fittingTransferDataRef" :rules="fittingTransferDataRules"
              el-position="top" class="df fww jcsb">
              <el-form-item label="调出仓库：" style="width: 48%">
                <el-input v-model="fittingTransferData.warehouseName" disabled />
              </el-form-item>
              <el-form-item label="调出区域：" style="width: 48%">
                <el-input v-model="fittingTransferData.warehouseArea" disabled />
              </el-form-item>
              <el-form-item label="配件名称：" style="width: 48%">
                <el-input v-model="fittingTransferData.fittingName" disabled />
              </el-form-item>
              <el-form-item label="配件类型：" style="width: 48%">
                <el-input v-model="fittingTransferData.typeName" disabled />
              </el-form-item>
              <el-form-item label="车型：" style="width: 48%">
                <el-input type="textarea" v-model="fittingTransferData.modelName" disabled />
              </el-form-item>
              <el-form-item label="车系：" style="width: 48%">
                <el-input v-model="fittingTransferData.series" disabled />
              </el-form-item>
              <el-form-item label="调入仓库：" style="width: 48%" prop="inWarehouseId">
                <el-select v-model="fittingTransferData.inWarehouseId" placeholder="调入仓库：" @change="changetransfer1">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="调入区域：" style="width: 48%" prop="transferInArea">
                <el-cascader v-model="fittingTransferData.transferInArea" placeholder="存储位置" :options="optionsAlot"
                  filterable style="width: 100%" @focus="changeAreaAlot1" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="fittingTransferDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="fittingTransferBtn(fittingTransferDataRef)">调拨</el-button>
              </span>
            </template>
          </el-dialog>
        </el-tab-pane>
        <!-- ********** 非溯源件 ********** -->
        <el-tab-pane name="second">
          <template #label>
            <span>非溯源件</span>
          </template>
          <!-- ############################################## 查询 ############################################## -->
          <div class="top" >
            <el-form :model="searchParts">
              <div class="df fww">
                <el-form-item v-if="cmopany == 0" label="公司名称：" class="mr20" style="width: 20%">
                  <el-select v-model="searchParts.companyNode" filterable placeholder="公司名称">
                    <el-option v-for="item in companyList" :key="item.id" :label="item.companyName"
                      :value="item.node" />
                  </el-select>
                </el-form-item>
                <el-form-item label="配件分类：" class="mr20" style="width: 20%">
                  <el-select v-model="searchParts.partsType" placeholder="类型">
                    <el-option v-for="item in PartsList" :key="item.type_id" :label="item.type_name"
                      :value="item.type_id" />
                  </el-select>
                </el-form-item>
                <el-form-item label="仓库名称" style="width: 20%">
                  <el-select v-model="searchParts.storeId" placeholder="仓库名称：" class="mr20" filterable>
                    <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                      :value="item.warehouseId" />
                  </el-select>
                </el-form-item>
                <el-form-item style="width: 20%">
                  <el-button type="primary" @click="searchPartsBtn">查询</el-button>
                  <el-button type="primary" plain @click="rescPartsBtn">重置</el-button>
                </el-form-item>
              </div>
            </el-form>
          </div>
          <el-divider />
          <div class="mb20">
            <el-button type="primary" @click="InDialogVisibleDialogVisible = true" v-if='roleList.write'>入库</el-button>
            <el-button type="primary" plain @click="exportExcelParts" v-if='roleList.write'>导出数据</el-button>
          </div>
          <div class="cyr-flex-box">
          <el-table @selection-change="handleSelectionChange" :data="PatstableData"
             :header-cell-style="{ background: '#f0f6fe' }" :show-overflow-tooltip="true" v-adaptive border>
            <el-table-column type="selection" width="50" />
            <el-table-column label="配件编号" prop="id" />
            <el-table-column label="配件类型" prop="type_name" />
            <el-table-column label="配件数量" prop="partsNum" />
            <el-table-column label="仓库名称" prop="warehouseName" />
            <el-table-column label="创建时间" prop="createdAt" />
            <el-table-column label="更新时间" prop="updatedAt" />
            <el-table-column fixed="right" label="操作">
              <template #default="props">
                <el-button size="small" link type="primary" @click="partsDetails(props.row)">详情</el-button>
                <el-button size="small" link type="primary" @click="partsOutBoundDialog(props.row)"
                  v-if='roleList.write'>出库</el-button>
                <el-button size="small" link type="primary" @click="partsTTransferDialog(props.row)"
                  v-if='roleList.write'>调拨</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <smartPager v-model:current-page="currentPage1" v-model:page-size="pageSize1" :total="Number(total1)"
            @change="handleCurrentChange1" />
          </div>
          <!-- ############################################## 蒙层---非溯源件 ############################################## -->
          <!-- ****************************** 非溯源件详情 ****************************** -->
          <el-drawer v-model="partsDrawer" size="50%" style="background: #f5f9ff">
            <div class="drawer_top p20">
              <h1 style="font-weight: 700; font-size: 18px; color: #3d3d3d">
                {{ partsDetailsData.type_name }}
              </h1>
              <span style="color: #9e9e9e; font-size: 12px">更新时间：{{ partsDetailsData.updatedAt }}</span>
              <el-divider style="margin: 10px 0" />
              <el-form :model="PastseditformData" label-width="120" label-position="left" class="df fww">
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">配件编号：</p>
                    </div>
                  </template>
                  <el-text>{{ PastseditformData.id }}</el-text>
                </el-form-item>
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">配件名称：</p>
                    </div>
                  </template>
                  <el-text>{{ PastseditformData.type }}</el-text>
                </el-form-item>
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">仓库名称：</p>
                    </div>
                  </template>
                  <el-text>{{ PastseditformData.warehouseName }}</el-text>
                </el-form-item>
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">仓库编码：</p>
                    </div>
                  </template>
                  <el-text>{{ PastseditformData.storeId }}</el-text>
                </el-form-item>
                <!-- <el-form-item style="width: 50%;">
                                    <template #label>
                                        <div class="df aic">
                                            <el-icon color="#9e9e9e" class="mr6">
                                                <User />
                                            </el-icon>
                                            <p style="color: #9e9e9e;">定价：</p>
                                        </div>
                                    </template>
                                    <el-text>￥{{ PastseditformData.price }}</el-text>
                                </el-form-item> -->
                <!-- <el-form-item style="width: 50%;">
                                    <template #label>
                                        <div class="df aic">
                                            <el-icon color="#9e9e9e" class="mr6">
                                                <User />
                                            </el-icon>
                                            <p style="color: #9e9e9e;">仓储位置：</p>
                                        </div>
                                    </template>
                                    <el-text v-if="flag == true">{{ PastseditformData.storageLocation }}</el-text>
                                    <el-input v-else v-model="PastseditformData.storageLocation" />
                                </el-form-item> -->
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">库存数量：</p>
                    </div>
                  </template>
                  <el-text type="primary">{{ PastseditformData.partsNum }}</el-text>
                </el-form-item>
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">低储：</p>
                    </div>
                  </template>
                  <el-input-number v-model="maxStock" :step="1" step-strictly style="width: 80%" :disabled="flag" />
                </el-form-item>
                <el-form-item style="width: 50%">
                  <template #label>
                    <div class="df aic">
                      <el-icon color="#9e9e9e" class="mr6">
                        <User />
                      </el-icon>
                      <p style="color: #9e9e9e">高储：</p>
                    </div>
                  </template>
                  <el-input-number v-model="minStock" :step="1" step-strictly style="width: 80%" :disabled="flag" />
                </el-form-item>
              </el-form>
              <div class="df jcc">
                <div>
                  <el-button type="primary" size="small" @click="editDetails" v-if='roleList.write'>修改</el-button>
                  <el-button type="primary" size="small" plain @click="saveDetails" v-if='roleList.write'>保存</el-button>
                </div>
              </div>
            </div>
            <div class="drawer_top p20 mt20">
              <div class="df aic jcc">非溯源件统计明细</div>
              <!-- <div class=" df jcsb">
                                <div class="mr10">
                                    <el-select v-model="select" placeholder="明细类型" style="width: 115px">
                                        <el-option label="Restaurant" value="1" />
                                        <el-option label="Order No." value="2" />
                                        <el-option label="Tel" value="3" />
                                    </el-select>
                                </div>
                                <div style="width: 50%;" class="df aic b0 mr10">
                                    <el-select v-model="select" placeholder="明细类型" style="width: 30%;">
                                        <el-option label="Restaurant" value="1" />
                                        <el-option label="Order No." value="2" />
                                        <el-option label="Tel" value="3" />
                                    </el-select>
                                    <el-date-picker v-model="timeValue" type="datetimerange" range-separator="To"
                                        start-placeholder="Start date" end-placeholder="End date" />
                                </div>
                                <div class="DocumentNumber">
                                    <el-input v-model="input" placeholder="Please input" class="input-with-select">
                                        <template #prepend>
                                            <el-select v-model="select" placeholder="单据编号"
                                                style="width: 100px;background-color: #fff;">
                                                <el-option label="Restaurant" value="1" />
                                                <el-option label="Order No." value="2" />
                                                <el-option label="Tel" value="3" />
                                            </el-select>
                                        </template>
                                        <template #append>
                                            <el-button :icon="Search"></el-button>
                                        </template>
                                    </el-input>
                                </div>
                            </div> -->
              <el-table :data="PastseditTableData" style="width: 100%" class="mt20"
                :header-cell-style="{ background: '#f5f7fa' }" border max-height="240">
                <el-table-column label="操作时间" prop="updatedAt" :show-overflow-tooltip="true" />
                <!-- <el-table-column label="配件编号" prop="partsId" :show-overflow-tooltip="true" /> -->
                <el-table-column label="配件名称" prop="partsName" :show-overflow-tooltip="true" />
                <el-table-column label="仓库名" prop="warehouseName" :show-overflow-tooltip="true" />
                <el-table-column label="仓库位置" prop="adress" :show-overflow-tooltip="true" />
                <el-table-column label="库存数量" prop="num" :show-overflow-tooltip="true" />
                <!-- <el-table-column label="备注" prop="partsDescription" :show-overflow-tooltip="true" /> -->
              </el-table>
            </div>
          </el-drawer>
          <!-- ****************************** 非溯源件入库 ****************************** -->
          <el-dialog v-model="InDialogVisibleDialogVisible" title="非溯源件入库" width="40%" align-center
            @close="closeInDialogVisibleDialogVisible">
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">非溯源件入库</p>
              </div>
            </template>
            <el-form :model="outDataat" ref="outDataatRef" :rules="outDataatRules" label-position="top"
              class="df fww jcsb">
              <el-form-item label="入库方式：" style="width: 48%" prop="status">
                <el-select v-model="outDataat.status" placeholder="方式">
                  <el-option label="手动录入" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="非溯源件类型：" style="width: 48%" prop="partsTypeName">
                <el-select v-model="outDataat.partsTypeName" placeholder="类型" filterable allow-create
                  default-first-option>
                  <el-option v-for="item in PartsList" :key="item.type_id" :label="item.type_name"
                    :value="item.type_name" />
                </el-select>
              </el-form-item>
              <el-form-item label="非溯源件名称：" style="width: 48%" prop="partsName">
                <el-input v-model="outDataat.partsName" placeholder="名称" />
              </el-form-item>
              <el-form-item label="入库仓库：" style="width: 48%" prop="storeId">
                <el-select v-model="outDataat.storeId" placeholder="仓库" @change="changeWareHouse">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="存储位置：" style="width: 48%" prop="storageLocation">
                <el-cascader v-model="outDataat.storageLocation" placeholder="位置" :options="options" filterable
                  @focus="changeArea" />
              </el-form-item>
              <el-form-item label="入库数量：" style="width: 48%" prop="num">
                <el-input v-model.number="outDataat.num" placeholder="数量" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="InDialogVisibleDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="InPutParts(outDataatRef)" :loading="loading">
                  入库
                </el-button>
              </span>
            </template>
          </el-dialog>
          <!-- ****************************** 非溯源件出库 ****************************** -->
          <el-dialog v-model="outBoundDialogVisible" title="非溯源件出库" width="40%" align-center>
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">非溯源件出库</p>
              </div>
            </template>
            <el-form :model="outBoundData" label-position="top" class="df fww jcsb">
              <el-form-item label="出库类型：" style="width: 48%">
                <el-select v-model="outBoundData.status" placeholder="出库类型：">
                  <el-option label="销售出库" value="0" />
                </el-select>
              </el-form-item>
              <el-form-item label="仓库编号：" style="width: 48%">
                <el-select v-model="outBoundData.warehouseId" placeholder="仓库编号：">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="非溯源件类型：" style="width: 48%">
                <el-select v-model="outBoundData.productType" placeholder="非溯源件类型：">
                  <el-option v-for="item in PartsList" :key="item.type_id" :label="item.type_name"
                    :value="item.type_id" />
                </el-select>
              </el-form-item>
              <el-form-item label="出库数量：" style="width: 48%">
                <el-input v-model="outBoundData.num" placeholder="出库数量：" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="outBoundDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="outBoundParts"> 出库 </el-button>
              </span>
            </template>
          </el-dialog>
          <!-- ****************************** 非溯源件出库 ****************************** -->
          <el-dialog v-model="partsOutBoundDialogVisible" width="40%" align-center>
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">非溯源件出库</p>
              </div>
            </template>
            <el-form :model="partsOutBoundData" ref="partsOutBoundDataRef" label-position="top" class="df fww jcsb">
              <el-form-item label="出库仓库：" style="width: 48%">
                <el-input v-model="partsOutBoundData.warehouseName" disabled />
              </el-form-item>
              <el-form-item label="配件类型：" style="width: 48%">
                <el-input v-model="partsOutBoundData.type_name" disabled />
              </el-form-item>
              <el-form-item label="仓库数量：" style="width: 48%">
                <el-input v-model="partsOutBoundData.partsNum" disabled />
              </el-form-item>
              <!-- <el-form-item label="出库类型：" style="width: 48%;">
                                <el-select v-model="partsOutBoundData.status">
                                    <el-option label="销售出库" value="0" />
                                </el-select>
                            </el-form-item> -->
              <el-form-item label="出库数量：" :rules="[
                { required: true, message: '输入出库数量' },
                { type: 'number', message: '出库数量必须是数字' },
              ]" prop="num" style="width: 48%">
                <el-input v-model.number="partsOutBoundData.num" placeholder="出库数量" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="partsOutBoundDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="partsOutBoundBtn(partsOutBoundDataRef)"> 出库 </el-button>
              </span>
            </template>
          </el-dialog>
          <!-- ****************************** 非溯源件调拨 ****************************** -->
          <el-dialog v-model="LinDiaoBoDialogVisible" title="非溯源件调拨" width="40%" align-center>
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">非溯源件调拨</p>
              </div>
            </template>
            <el-form :model="partstransferData" label-position="top" class="df fww jcsb">
              <el-form-item label="调出仓库：" style="width: 48%">
                <el-select v-model="partstransferData.outWarehouseId" placeholder="请选择调出仓库">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="调入仓库：" style="width: 48%">
                <el-select v-model="partstransferData.inWarehouseId" placeholder="请选择调入仓库" @change="changeAreaParts">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="调入区域：" style="width: 48%">
                <el-cascader v-model="partstransferData.transferInArea" placeholder="位置" :options="optionsParts"
                  filterable @focus="changeAreaPartsFocus" />
              </el-form-item>
              <el-form-item label="调拨商品：" style="width: 48%">
                <el-select v-model="partstransferData.productType" placeholder="请选择调拨商品">
                  <el-option v-for="item in PartsList" :key="item.type_id" :label="item.type_name"
                    :value="item.type_id" />
                </el-select>
              </el-form-item>
              <!-- <el-form-item label="调拨状态：" style="width: 48%;">
                                <el-select v-model="partstransferData.transferStatus" placeholder="请选择调拨状态">
                                    <el-option label="0" value="0" />
                                    <el-option label="1" value="1" />
                                    <el-option label="2" value="2" />
                                </el-select>
                            </el-form-item> -->
              <el-form-item label="调拨数量：" style="width: 48%">
                <el-input v-model="partstransferData.num" placeholder="请输入调拨数量" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="LinDiaoBoDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="partsTransfer"> 调拨 </el-button>
              </span>
            </template>
          </el-dialog>
          <!-- ****************************** 非溯源件调拨 ****************************** -->
          <el-dialog v-model="partsTTransferDialogVisible" width="40%" align-center>
            <template #header>
              <div class="df aic">
                <el-icon style="color: #fff" size="20">
                  <Edit />
                </el-icon>&nbsp;
                <p style="color: #fff">非溯源件调拨</p>
              </div>
            </template>
            <el-form :model="partsTTransferData" ref="partsTTransferDataRef" label-position="top" class="df fww jcsb">
              <el-form-item label="调出仓库：" style="width: 48%">
                <el-input v-model="partsTTransferData.warehouseName" disabled />
              </el-form-item>
              <el-form-item label="调拨类型：" style="width: 48%">
                <el-input v-model="partsTTransferData.type_name" disabled />
              </el-form-item>
              <el-form-item label="库存数量：" style="width: 48%">
                <el-input v-model="partsTTransferData.partsNum" disabled />
              </el-form-item>
              <el-form-item label="调入仓库：" :rules="[
                { required: true, message: '输入调入仓库' },
              ]" prop="inWarehouseId" style="width: 48%">
                <el-select v-model="partsTTransferData.inWarehouseId" placeholder="请选择调入仓库" @change="changeAreaParts1">
                  <el-option v-for="item in WarehouseList" :key="item.warehouseId" :label="item.warehouseName"
                    :value="item.warehouseId" />
                </el-select>
              </el-form-item>
              <el-form-item label="调入区域：" :rules="[
                { required: true, message: '输入调入区域' },
              ]" prop="transferInArea" style="width: 48%">
                <el-cascader v-model="partsTTransferData.transferInArea" placeholder="位置" :options="optionsParts"
                  filterable @focus="changeAreaPartsFocus1" />
              </el-form-item>
              <el-form-item label="调拨数量：" :rules="[
                { required: true, message: '输入出库数量' },
                { type: 'number', message: '出库数量必须是数字' },
              ]" prop="num" style="width: 48%">
                <el-input v-model.number="partsTTransferData.num" placeholder="请输入调拨数量" />
              </el-form-item>
            </el-form>

            <template #footer>
              <span class="dialog-footer">
                <el-button type="primary" plain @click="partsTTransferDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="partsTTransferBtn(partsTTransferDataRef)" :loading="loading">
                  调拨
                </el-button>
              </span>
            </template>
          </el-dialog>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import { formatTime, formatTimeHan } from "@/filters/index";
import { ElMessage } from "element-plus";
import {
  RequestFittingsGetlistlimit,
  RequestTransferSave,
  RequestFittingsFittingOutbound,
  RequestFittingsSave,
  RequestWarehouseList,
  RequestPartsStatisticGetlistlimit,
  RequestPartsGetPartsType,
  RequestPartsSave,
  RequestPartsPartsOutbound,
  RequestEmployeeGetFunctionAuthorize,
  RequestpartsStatisticDetail,
  RequestInventoryWarnningGetWarningByStatisticId,
  RequestInventoryGetProduct,
  RequestCompanyList,
  RequestInventoryWarnningSave,
  RequestPartsGetPartsDetail,
  RequestUpWarehouseAreaGetAreaInfo,
  RequestCarType,
  RequestCarSeries,
  RequestCarBrand,
  RequestPartsStatisticOutputExcel,
  RequestFittingsOutputExcel,
  RequestCarModelCreateCarModelInfo
} from "@/api/path/index.js";
import { exportFile } from "@/utils/exportFile.js";
import { Wallet, User, Search, Edit, ArrowDown, ArrowUp } from "@element-plus/icons-vue";
import { ref } from "vue";
const loading = ref<any>(false);
const activeName = ref("first");
const editformDataRef = ref<any>()
const editformDataRefRules = ref<any>({
  status: [
    { required: true, message: '请选择入库类型', trigger: 'change' },
  ],
  warehouseId: [
    { required: true, message: '请选择入库仓库', trigger: 'change' },
  ],
})
/*------------------------------------- 按钮权限 -------------------------------------*/
import useAuthorize from "@/hooks/authorize";
let roleList = useAuthorize()
// import { useRouter } from "vue-router";
// const authorizeFlag = ref<any>();
// const btnAuthority = () => {
//   RequestEmployeeGetFunctionAuthorize(useRouter().currentRoute.value.meta.title).then(
//     (res: any) => {
//       if (res.resultObj == "W") {
//         authorizeFlag.value = false;
//       } else {
//         authorizeFlag.value = true;
//       }
//     }
//   );
// };
// btnAuthority();
/*------------------------------------- 按钮权限 -------------------------------------*/
const InDialogVisible = ref<any>(false);
const outDialogVisible = ref<any>(false);
const diaoDialogVisible = ref<any>(false);
const AddDialogVisible = ref<any>(false);
const InDialogVisibleDialogVisible = ref<any>(false); //非溯源件入库
const outBoundDialogVisible = ref<any>(false); //非溯源件出库
const LinDiaoBoDialogVisible = ref<any>(false); //非溯源件调拨

/* ******************************************* 分页获取数据 ********************************************/
const total = ref<any>(8);
const currentPage = ref(1);
const pageSize = ref(10);

/*********************************** 溯源件查询 ***********************************/
const searchFittings = ref<any>({
  fittingName: null,
  typeId: null,
  brand: null,
  series: null,
  modelName: null,
  warehouseName: null,
  dismantleTeamName: null,
  description: null,
});
const searchFittingsBtn = () => {
  // console.log(searchFittings.value);
  getData();
  console.log(1231313131);
};
/* ********************************************************************** 获取公司列表 ***********************************************************************/
const cmopany = JSON.parse(localStorage.getItem("roleInfo")!).company;
const companyList = ref<any>([]);
const getCompanyList = () => {
  if (JSON.parse(localStorage.getItem("roleInfo")!).company == 0) {
    RequestCompanyList().then((res: any) => {
      console.log(res.resultObj);
      companyList.value = res.resultObj;
    });
  }
};
getCompanyList();
const getData = () => {
  RequestFittingsGetlistlimit({
    page: currentPage.value,
    rows: pageSize.value,
    storeId: searchFittings.value.warehouseName,
    model: searchFittings.value.model,
    series: searchFittings.value.series,
    brand: searchFittings.value.brand,
    modelName: searchFittings.value.modelName,
    fittingName: searchFittings.value.fittingName,
    typeId: searchFittings.value.typeId,
    companyNode: searchFittings.value.companyNode,
    dismantleTeamName: searchFittings.value.dismantleTeamName,
    description: searchFittings.value.description,
  }).then((res: any) => {
    total.value = res.resultObj.total;
    tableData.value = res.resultObj.data;
    tableData.value.forEach((item: any) => {
      item.created = formatTime(item.createdAt)
    })
  });
};
getData();
const rescFittings = () => {
  console.log(456456456);
  currentPage.value = 1;
  (searchFittings.value.warehouseName = null),
    (searchFittings.value.model = null),
    (searchFittings.value.series = null),
    (searchFittings.value.brand = null),
    (searchFittings.value.fittingName = null),
    (searchFittings.value.typeId = null),
    (searchFittings.value.modelName = null),
    (searchFittings.value.companyNode = null),
    (searchFittings.value.description = null),
    (searchFittings.value.dismantleTeamName = null),
    getData();
};
const shopGoodsList = ref<any>([]); //获取商品类别
const getShopGoods = () => {
  RequestInventoryGetProduct(1).then((res: any) => {
    shopGoodsList.value = res.resultObj;
  });
};
getShopGoods();
const brandList = ref<any>([]);

const Addproducta = async (formEl: any | undefined) => {
  if (!formEl) return
  await formEl.validate((valid: any, fields: any) => {
    if (valid) {
      AddDialogVisible.value = true;
      RequestCarBrand("").then((res: any) => {
        brandList.value = JSON.parse(
          JSON.stringify(res.resultObj)
            .replaceAll("firstLetter", "letter")
            .replaceAll("brands", "data")
        );
      });
    } else {
      console.log("error submit!", fields);
    }
  })
}
// const Addproducta = async () => {

// };
const AddProductFormData = ref<any>({
  fittingName: "",
  fittingDescription: "",
  typeId: "",
  brand: "",
  series: "",
  model: "",
  storageLocation: "",
  storeId: "",
  oeCode: '',
});

const tableData = ref<any>([]);
const outBoundTableDataslect = ref<any>([]); //出库单需要的产品
const allotTableDataslect = ref<any>([]); //调拨单需要的产品
const handleSelectionChange = (val: any) => {
  console.log("select", val);
  outBoundTableDataslect.value = val;
  allotTableDataslect.value = val;
  // val.forEach((element: any) => {
  //     outBoundTableDataslect.value.push(element)
  //     allotTableDataslect.value.push(element)
  // });
};
const drawer = ref(false); //详情
const partsDrawer = ref(false); //非溯源件详情详情
// 分页
const handleSizeChange = (val: number) => {
  console.log(val);
  getData();
};
const handleCurrentChange = (val: number) => {
  console.log(val);
  getData();
};
/* ************************ 获取仓库下拉数据 ************************ */
const WarehouseList = ref<any>([]);
const getWarehouseList = () => {
  RequestWarehouseList().then((res: any) => {
    WarehouseList.value = res.resultObj;
  });
};
getWarehouseList();
/* ******************************************* 详情 ********************************************/
const details = (row: any) => {
  row.status = String(row.status)
  editformData.value = row;
  drawer.value = true;
  console.log(editformData.value);
};
/* ******************************************* 添加入库单 ********************************************/
const editformData = ref<any>({});
const options1 = ref<any>([]);
const changeWareHouse1 = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    console.log(res.resultObj);
    res.resultObj.forEach((item: any) => {
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.position + '&' + val.id;
      });
    });
    options1.value = res.resultObj;
  });
};
//   fittingName: "",
//   fittingDescription: "",
//   typeId: "",
//   brand: "",
//   series: "",
//   model: "",
//   storageLocation: "",
//   storeId: "",
//   oeCode: '',
const AddProductTableData = ref<any>([]);
const ruleFormRef = ref<any>()
const rules = ref<any>({
  fittingName: [
    { required: true, message: '请输入配件名', trigger: 'blur' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  fittingDescription: [
    { required: true, message: '请输入配件描述', trigger: 'blur' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  typeName: [
    { required: true, message: '请选择配件类型', trigger: 'change' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'change' },
  ],
  brand: [
    { required: true, message: '请选择品牌', trigger: 'change' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'change' },
  ],
  series: [
    { required: true, message: '请选择车系', trigger: 'change' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'change' },
  ],
  modelName: [
    { required: true, message: '请选择车型', trigger: 'change' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'change' },
  ],
  storageLocation: [
    { required: true, message: '请选择仓储位置', trigger: 'blur' },
    // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  // storeId: [
  //   { required: true, message: 'Please input Activity name', trigger: 'blur' },
  //   { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  // ],
})
const closeAddDialogVisible = () => {
  console.log('closeAddDialogVisible');

  AddProductFormData.value.fittingName = ''
  AddProductFormData.value.fittingDescription = ''
  AddProductFormData.value.typeName = ''
  AddProductFormData.value.brand = ''
  AddProductFormData.value.series = ''
  AddProductFormData.value.model = ''
  AddProductFormData.value.modelName = ''
  AddProductFormData.value.storageLocation = ''
  AddProductFormData.value.oeCode = ''
}
/* ***************** 添加入库单-添加产品 ***************** */
const AddProductData = async (formEl: any | undefined) => {
  if (!formEl) return
  await formEl.validate((valid: any, fields: any) => {
    if (valid) {
      if (AddProductFormData.value.model == '') {
        RequestCarModelCreateCarModelInfo({
          brand: AddProductFormData.value.brand,
          series: AddProductFormData.value.series,
          model: AddProductFormData.value.modelName,
        }).then((res: any) => {
          if (res.success == true) {
            AddProductFormData.value.model = res.resultObj
            AddDialogVisible.value = false;
            let arrObj = JSON.parse(JSON.stringify(AddProductFormData.value));
            AddProductTableData.value.push(arrObj);
          }
        })
      } else {
        AddDialogVisible.value = false;
        AddProductFormData.value.storageLocationTab = AddProductFormData.value.storageLocation[0] + '/' + AddProductFormData.value.storageLocation[1].split('&')[0]
        AddProductFormData.value.storageLocation = [AddProductFormData.value.storageLocation[0], Number(AddProductFormData.value.storageLocation[1].split('&')[1])]
        let arrObj = JSON.parse(JSON.stringify(AddProductFormData.value));
        AddProductTableData.value.push(arrObj);
      }
      console.log(AddProductFormData.value)
      console.log(AddProductTableData.value)
    } else {
      console.log('error submit!', fields)
    }
  })

  // }
};
/* ***************** 添加入库单-移除 ***************** */
const removeAddProductTableData = (index: any) => {
  AddProductTableData.value.splice(index, 1);
};
const submitSingle = () => {
  if (AddProductTableData.value.length > 0) {
    loading.value = true;
    console.log("AddProductTableData.value", AddProductTableData.value);
    console.log("editformData.value", editformData.value);
    AddProductTableData.value.forEach((item: any) => {
      item.storageLocation = item.storageLocation[1];
    });
    const blob = new Blob(
      [
        JSON.stringify({
          productType: 1,
          warehouseId: editformData.value.warehouseId,
          supplierId: editformData.value.supplierId,
          marks: editformData.value.marks,
          inboundType: 2,
        }),
      ],
      {
        type: "application/json;charset=utf-8",
      }
    );
    const blob2 = new Blob([JSON.stringify(AddProductTableData.value)], {
      type: "application/json;charset=utf-8",
    });
    const SaveData = new FormData();
    SaveData.append("inbound", blob);
    SaveData.append("fittings", blob2);
    RequestFittingsSave(SaveData).then((res: any) => {
      if (res.success == true) {
        ElMessage.success(res.msg);
        AddProductTableData.value = [];
        AddProductFormData.value.fittingName = "";
        AddProductFormData.value.fittingDescription = "";
        AddProductFormData.value.typeId = "";
        AddProductFormData.value.brand = "";
        AddProductFormData.value.series = "";
        AddProductFormData.value.model = "";
        AddProductFormData.value.storageLocation = "";
        AddProductFormData.value.storeId = "";
        editformData.value = {};
        InDialogVisible.value = false;
        getShopGoods();
        setTimeout(() => {
          loading.value = false;
        }, 200);
        getData();
      } else {
        ElMessage.error(res.msg);
      }
      console.log(res);
    });
  } else {
    ElMessage.error('请填写完整数据')
  }
};
const closeInDialogVisible = () => {
  editformData.value.status = ''
  editformData.value.warehouseId = ''
}
/* ******************************************* 添加出库单 ********************************************/
const removeOutBoundTableDataslect = ref<any>([]);
const outbound = () => {
  removeOutBoundTableDataslect.value = [];
  if (outBoundTableDataslect.value.length) {
    let checkWarehouseName = outBoundTableDataslect.value.every(
      (obj: any) => obj.warehouseName === allotTableDataslect.value[0].warehouseName
    );
    if (checkWarehouseName) {
      outDialogVisible.value = true;
      outBoundTableData.value.warehouseId = outBoundTableDataslect.value[0].storeId;
    } else {
      ElMessage.error("请勾选同一仓库的溯源件");
    }
  } else {
    ElMessage.error("请勾选需要出库的溯源件");
  }
  // outDialogVisible.value = true
  /* 去重 */
  for (let i = 0; i < outBoundTableDataslect.value.length; i++) {
    removeOutBoundTableDataslect.value.includes(outBoundTableDataslect)
      ? removeOutBoundTableDataslect.value
      : removeOutBoundTableDataslect.value.push(outBoundTableDataslect.value[i]);
  }
};
const closeOutBound = () => {
  removeOutBoundTableDataslect.value = [];
};
const contentIdArr = ref<any>([]);
const outBoundTableData = ref<any>({
  remark: "",
  price: "",
  warehouseId: "",
  status: "",
});
const submitOutbound = () => {
  loading.value = true;
  removeOutBoundTableDataslect.value.forEach((item: any) => {
    contentIdArr.value.push(item.fittingId);
  });
  RequestFittingsFittingOutbound({
    warehouseId: outBoundTableData.value.warehouseId,
    // price: outBoundTableData.value.price,
    status: 0,
    // typeId: 1,
    // remark: outBoundTableData.value.remark,
    contentId: contentIdArr.value,
  }).then((res: any) => {
    if (res.code == 0) {
      ElMessage.success(res.msg);
      outDialogVisible.value = false;
      setTimeout(() => {
        loading.value = false;
      }, 200);
      getData();
    } else {
      ElMessage.error(res.msg);
    }
  });
};

/* ******************************************* 单个出库 ********************************************/
const fittingOutBoundDialogVisible = ref<any>(false);
const fittingOutBoundData = ref<any>({});
const fittingOutBoundIdArr = ref<any>([]);
const fittingsOutBoundDialog = (e: any) => {
  fittingOutBoundDialogVisible.value = true;
  // console.log(e);
  fittingOutBoundIdArr.value.push(e.fittingId);
  fittingOutBoundData.value = e;
  delete fittingOutBoundData.value.createdAt;
};
const closeFittingOutBoundDialogVisible = () => {
  fittingOutBoundData.value = {}
  fittingOutBoundIdArr.value = []
}
const fittingsOutBound = () => {
  RequestFittingsFittingOutbound({
    warehouseId: fittingOutBoundData.value.storeId,
    // price: outBoundTableData.value.price,
    status: fittingOutBoundData.value.status,
    // typeId: 1,
    // remark: outBoundTableData.value.remark,
    contentId: fittingOutBoundIdArr.value,
  }).then((res: any) => {
    if (res.success == true) {
      ElMessage.success(res.msg);
      fittingOutBoundDialogVisible.value = false;
      getData();
    } else {
      ElMessage.error(res.msg);
    }
  });
};
/* ******************************************* 调拨 ********************************************/
const removeAllotTableDataslect = ref<any>([]);
const closeTransfer = () => {
  removeAllotTableDataslect.value = [];
  transferData.value.inWarehouseId = ''
  transferData.value.transferInArea = ''
};
const transferSave = () => {
  removeAllotTableDataslect.value = [];
  if (allotTableDataslect.value.length) {
    let checkWarehouseName = allotTableDataslect.value.every(
      (obj: any) => obj.warehouseName === allotTableDataslect.value[0].warehouseName
    );
    if (checkWarehouseName) {
      diaoDialogVisible.value = true;
      transferData.value.outWarehouseId = allotTableDataslect.value[0].storeId;
    } else {
      ElMessage.error("请勾选同一仓库的溯源件");
    }
  } else {
    ElMessage.error("请勾选需要调拨的溯源件");
  }
  for (let i = 0; i < allotTableDataslect.value.length; i++) {
    removeAllotTableDataslect.value.includes(allotTableDataslect.value[i])
      ? removeAllotTableDataslect.value
      : removeAllotTableDataslect.value.push(allotTableDataslect.value[i]);
  }
};
const contentIdListArr = ref<any>([]);
const transferData = ref<any>({
  outWarehouseId: "",
  inWarehouseId: "",
  transferInArea: "",
  // transferStatus: '',
});
const optionsAlot = ref<any>([]);
const changetransfer = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      console.log(item);
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.id;
      });
    });
    optionsAlot.value = res.resultObj;
  });
};
const changeAreaAlot = () => {
  if (transferData.value.inWarehouseId == "") {
    ElMessage.error("请先选择入库仓库");
  }
};
const transfer = () => {
  loading.value = true;
  console.log("transferData", transferData.value);
  console.log("transferData", transferData.value.transferInArea[1]);
  removeAllotTableDataslect.value.forEach((item: any) => {
    contentIdListArr.value.push(item.fittingId);
  });
  const bold = new Blob(
    [
      JSON.stringify({
        outWarehouseId: transferData.value.outWarehouseId,
        inWarehouseId: transferData.value.inWarehouseId,
        transferInArea: transferData.value.transferInArea[1],
        // transferStatus: transferData.value.transferStatus,
        contentId: contentIdListArr.value,
        contentType: 1,
      }),
    ],
    {
      type: "application/json;charset=UTF-8",
    }
  );
  const transfer = new FormData();
  transfer.append("transfer", bold);
  RequestTransferSave(transfer).then((res: any) => {
    if (res.success == true) {
      ElMessage.success(res.msg);
      removeAllotTableDataslect.value = [];
      allotTableDataslect.value = [];
      transferData.value.outWarehouseId = "";
      transferData.value.inWarehouseId = "";
      transferData.value.transferInArea = "";
      diaoDialogVisible.value = false;
      setTimeout(() => {
        loading.value = false;
      }, 200);
      getData();
    } else {
      ElMessage.error(res.msg);
    }
  });
};
/* ******************************************* 单个调拨 ********************************************/
const fittingTransferDialogVisible = ref<any>(false);
const fittingTransferData = ref<any>({});
const fittingTransferIdArr = ref<any>([]);
const fittingTransferDialog = (e: any) => {
  fittingTransferDialogVisible.value = true;
  console.log(e);
  fittingTransferData.value = e;
  fittingTransferData.value.inWarehouseId = null;
  fittingTransferData.value.transferInArea = null;
  fittingTransferIdArr.value = [e.fittingId];
  delete fittingTransferData.value.createdAt;
};
const changetransfer1 = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      console.log(item);
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.id;
      });
    });
    optionsAlot.value = res.resultObj;
  });
};
const changeAreaAlot1 = () => {
  if (fittingTransferData.value.inWarehouseId == null) {
    ElMessage.error("请先选择入库仓库");
  } else {
    fittingTransferData.value.transferInArea = fittingTransferData.value.transferInArea[1];
  }
};
const fittingTransferDataRef = ref<any>()
const fittingTransferDataRules = ref<any>({
  inWarehouseId: [{ required: true, message: "请选择调入仓库", trigger: "change" }],
  transferInArea: [{ required: true, message: "请选择仓储位置", trigger: "change" }],
})
const fittingTransferBtn = async (formEl: any | undefined) => {
  if (!formEl) return;
  await formEl.validate((valid: any, fields: any) => {
    if (valid) {
      console.log(fittingTransferData.value);
      console.log(fittingTransferIdArr.value);

      const bold = new Blob(
        [
          JSON.stringify({
            outWarehouseId: fittingTransferData.value.storeId,
            inWarehouseId: fittingTransferData.value.inWarehouseId,
            transferInArea: fittingTransferData.value.transferInArea,
            contentId: fittingTransferIdArr.value,
            contentType: 1,
          }),
        ],
        {
          type: "application/json;charset=UTF-8",
        }
      );
      const transfer = new FormData();
      transfer.append("transfer", bold);
      RequestTransferSave(transfer).then((res: any) => {
        if (res.code == 0) {
          ElMessage.success(res.msg);
          fittingTransferDialogVisible.value = false;
          getData();
        } else {
          ElMessage.error(res.msg);
        }
      });
    } else {
      console.log("error submit!", fields);
    }
  });
};


/* ******************************************* 非溯源件---详情 ********************************************/
const maxStock = ref<any>(0);
const minStock = ref<any>(0);
const idsta = ref<any>();
const PastseditformData = ref<any>({});
const PastseditTableData = ref<any>([]);
const flag = ref<any>(true);
const partsDetailsData = ref<any>();
const partsDetails = (row: any) => {
  partsDetailsData.value = row;
  partsDrawer.value = true;
  RequestInventoryWarnningGetWarningByStatisticId(3, row.id).then((res: any) => {
    if (res.resultObj != null) {
      minStock.value = res.resultObj.minStock;
      maxStock.value = res.resultObj.maxStock;
      idsta.value = res.resultObj.id;
    }
  });
  RequestpartsStatisticDetail(row.id).then((res: any) => {
    PastseditformData.value = res.resultObj;
  });
  RequestPartsGetPartsDetail(row.id).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      item.createdAt = formatTime(item.createdAt);
      item.updatedAt = formatTime(item.updatedAt);
      item.adress = item.warehouseArea.area + "，" + item.warehouseArea.position;
    });
    PastseditTableData.value = res.resultObj;
    console.log(PastseditTableData.value);
  });
};
/* 修改 */
const editDetails = () => {
  flag.value = false;
};
/* 保存 */
const saveDetails = () => {
  flag.value = true;
  RequestInventoryWarnningSave({
    minStock: minStock.value,
    maxStock: maxStock.value,
    statisticId: PastseditformData.value.id,
    id: idsta.value,
    contentType: 3,
  }).then((res: any) => {
    if (res.code == 0) {
      ElMessage.success(res.msg);
      //其它处理代码
      getData();
    } else {
      ElMessage.error(res.msg);
    }
  });
};
/* ******************************************* 非溯源件---分页获取数据 ********************************************/
const PatstableData = ref<any>([]);
const total1 = ref<any>(8);
const currentPage1 = ref(1);
const pageSize1 = ref(10);
const searchParts = ref<any>({
  storeId: null,
  partsType: null,
});
const getPatsData = () => {
  RequestPartsStatisticGetlistlimit({
    page: currentPage1.value,
    rows: pageSize1.value,
    storeId: searchParts.value.storeId,
    partsType: searchParts.value.partsType,
    companyNode: searchParts.value.companyNode,
  }).then((res: any) => {
    res.resultObj.data.forEach((item: any) => {
      item.createdAt = formatTime(item.createdAt);
      item.updatedAt = formatTime(item.updatedAt);
    });
    total1.value = res.resultObj.total;
    PatstableData.value = res.resultObj.data;
  });
};
getPatsData();
const handleSizeChange1 = (val: number) => {
  console.log(val);
  getPatsData();
};
const handleCurrentChange1 = (val: number) => {
  console.log(val);
  getPatsData();
};
/*********************************** 非溯源件查询 ***********************************/
const searchPartsBtn = () => {
  getPatsData();
};
/* 重置 */
const rescPartsBtn = () => {
  currentPage1.value = 1;
  (searchParts.value.storeId = null),
    (searchParts.value.partsType = null),
    (searchParts.value.companyNode = null),
    getPatsData();
};
/* ******************************************* 非溯源件---入库 ********************************************/
const outDataat = ref<any>({
  partsDescription: "",
  storageLocationRacks: "",
  storageLocation: "",
  partsTypeName: "",
  storeId: "",
  // partsType: '',
  status: "",
  num: "",
  price: "",
  partsName: "",
});
const options = ref<any>([]);
const changeWareHouse = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      // console.log(item);
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.id;
      });
    });
    options.value = res.resultObj;
    console.log(res.resultObj);
  });
};
const asdasdada = (e) => {
  console.log(e);
}
const changeArea = () => {
  if (outDataat.value.storeId == "") {
    ElMessage.error("请先选择仓库");
  }
};
/* ************** 获取配件类型列表 ***************/
const PartsList = ref<any>([]);
const getPartsList = () => {
  RequestPartsGetPartsType().then((res: any) => {
    PartsList.value = res.resultObj;
  });
};
getPartsList();
const outDataatRef = ref()
const outDataatRules = reactive({
  status: [
    {
      required: true,
      message: "请选择入库方式",
      trigger: "change"
    }
  ],
  partsTypeName: [
    {
      required: true,
      message: "请选择类型",
      trigger: "change"
    }
  ],
  partsName: [
    {
      required: true,
      message: "请输入名称",
      trigger: "change"
    }
  ],
  storeId: [
    {
      required: true,
      message: "请选择入库仓库",
      trigger: "change"
    }
  ],
  storageLocation: [
    {
      required: true,
      message: "请选择存储位置",
      trigger: "change"
    }
  ],
  num: [
    {
      required: true,
      message: "请输入数量",
      trigger: "change"
    },
    {
      type: "number",
      message: "请输入数字",
      trigger: "change"
    }
  ]
})
const closeInDialogVisibleDialogVisible = () => {
  outDataat.value.status = ''
  outDataat.value.partsTypeName = ''
  outDataat.value.partsName = ''
  outDataat.value.storeId = ''
  outDataat.value.storageLocation = ''
  outDataat.value.num = ''
}
const InPutParts = async (formEl: any) => {
  if (!formEl) return;
  await formEl.validate((valid: any) => {
    if (valid) {
      console.log(outDataat.value);
      loading.value = true;
      RequestPartsSave({
        partsDescription: outDataat.value.partsDescription,
        storageLocation: outDataat.value.storageLocation[1],
        storeId: outDataat.value.storeId,
        // partsType: outDataat.value.partsType,
        status: outDataat.value.status,
        num: outDataat.value.num,
        price: outDataat.value.price,
        partsTypeName: outDataat.value.partsTypeName,
        partsName: outDataat.value.partsName,
        productType: 1,
      }).then((res: any) => {
        if (res.success == true) {
          ElMessage.success(res.msg);
          setTimeout(() => {
            loading.value = false;
          }, 1000);
          InDialogVisibleDialogVisible.value = false;
          getPartsList();
          getPatsData();
        } else {
          ElMessage.error(res.msg);
        }
      });
    }
  })

};
/* ******************************************* 非溯源件---出库 ********************************************/
const outBoundData = ref<any>({
  partsDescription: "",
  num: "",
  warehouseId: "",
  status: "",
  productType: "",
});
const outBoundParts = () => {
  console.log(outBoundData.value);
  RequestPartsPartsOutbound(outBoundData.value).then((res: any) => {
    if (res.code == 0) {
      ElMessage.success(res.msg);
      getPatsData();
      outBoundDialogVisible.value = false;
    } else {
      ElMessage.error(res.msg);
    }
  });
};
/* ******************************************* 非溯源件---出库 ********************************************/
const partsOutBoundDialogVisible = ref<any>(false);
const partsOutBoundData = ref<any>({
  num: 0,
});
const partsOutBoundDialog = (e: any) => {
  partsOutBoundData.value = e;
  partsOutBoundData.value.num = null;
  partsOutBoundData.value.productType = e.partsType;
  partsOutBoundData.value.warehouseId = e.storeId;
  partsOutBoundData.value.status = 0;
  partsOutBoundDialogVisible.value = true;
};
const partsOutBoundDataRef = ref()
const partsOutBoundBtn = async (formEl: any) => {
  if (!formEl) return
  await formEl.validate((valid: any) => {
    if (valid) {
      console.log(partsOutBoundData.value);
      delete partsOutBoundData.value.createdAt;
      delete partsOutBoundData.value.updatedAt;

      RequestPartsPartsOutbound(partsOutBoundData.value).then((res: any) => {
        if (res.code == 0) {
          ElMessage.success(res.msg);
          getPatsData();
          partsOutBoundDialogVisible.value = false;
        } else {
          ElMessage.error(res.msg);
        }
      });
    }
  })

};

/* ******************************************* 非溯源件---调拨 ********************************************/
const partstransferData = ref<any>({
  num: "",
  // transferStatus: '',
  inWarehouseId: "",
  transferInArea: "",
  outWarehouseId: "",
  contentType: 3,
});
const optionsParts = ref<any>([]);
const changeAreaParts = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      console.log(item);
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.id;
      });
    });
    optionsParts.value = res.resultObj;
  });
};
const changeAreaPartsFocus = () => {
  if (partstransferData.value.inWarehouseId == "") {
    ElMessage.error("请先选择入库仓库");
  }
};
const partsTransfer = () => {
  const bold = new Blob(
    [
      JSON.stringify({
        num: partstransferData.value.num,
        productType: partstransferData.value.productType,
        inWarehouseId: partstransferData.value.inWarehouseId,
        transferInArea: partstransferData.value.transferInArea[1], //调整
        outWarehouseId: partstransferData.value.outWarehouseId,
        contentType: partstransferData.value.contentType,
      }),
    ],
    {
      type: "application/json;charset=UTF-8",
    }
  );
  const transfer = new FormData();
  transfer.append("transfer", bold);
  RequestTransferSave(transfer).then((res: any) => {
    if (res.code == 0) {
      ElMessage.success(res.msg);
      partstransferData.value.num = "";
      partstransferData.value.productType = "";
      partstransferData.value.inWarehouseId = "";
      partstransferData.value.transferInArea = "";
      partstransferData.value.outWarehouseId = "";
      partstransferData.value.contentType = "";
      getPatsData();
      LinDiaoBoDialogVisible.value = false;
    } else {
      ElMessage.error(res.msg);
    }
  });
};
/* ******************************************* 非溯源件---调拨 ********************************************/
const partsTTransferDialogVisible = ref<any>(false);
const partsTTransferData = ref<any>({});
const partsTTransferDialog = (e: any) => {
  console.log(e);
  partsTTransferData.value = e;
  partsTTransferDialogVisible.value = true;
  partsTTransferData.value.inWarehouseId = null;
  partsTTransferData.value.outWarehouseId = e.storeId;
  partsTTransferData.value.productType = e.partsType;
  partsTTransferData.value.contentType = 3;
  partsTTransferData.value.num = null;
};
const partsTTransferDataRef = ref()
const partsTTransferBtn = async (formEl: any) => {
  if (!formEl) return
  await formEl.validate((valid: any) => {
    if (valid) {
      loading.value = true;
      delete partsTTransferData.value.updatedAt;
      delete partsTTransferData.value.createdAt;
      console.log(partsTTransferData.value);
      const bold = new Blob([JSON.stringify(partsTTransferData.value)], {
        type: "application/json;charset=UTF-8",
      });
      const transfer = new FormData();
      transfer.append("transfer", bold);
      RequestTransferSave(transfer).then((res: any) => {
        if (res.success == true) {
          ElMessage.success(res.msg);
          setTimeout(() => {
            loading.value = false;
          }, 200);
          getPatsData();
          partsTTransferDialogVisible.value = false;
        } else {
          ElMessage.error(res.msg);
          setTimeout(() => {
            loading.value = false;
          }, 200);
        }
      });
    }
  })

};
const changeAreaParts1 = (event: any) => {
  RequestUpWarehouseAreaGetAreaInfo(event).then((res: any) => {
    res.resultObj.forEach((item: any) => {
      console.log(item);
      item.label = item.area;
      item.value = item.area;
      item.children = item.list;
      item.list.forEach((val: any) => {
        val.label = val.position;
        val.value = val.id;
      });
    });
    optionsParts.value = res.resultObj;
  });
};
const changeAreaPartsFocus1 = () => {
  if (partsTTransferData.value.inWarehouseId == null) {
    ElMessage.error("请先选择入库仓库");
  } else {
    partsTTransferData.value.transferInArea = partsTTransferData.value.transferInArea[1];
  }
};
/* ******************************************* 品牌车型车系 ********************************************/
const carType = ref<any>([]); //车型
const carSeriesList = ref<any>([]); //车系
const activeStep = ref();
const brandIndex = ref();
const wortIndex = ref();
const inpVal = ref();
const visible = ref(false);
const visibleSerise = ref(false);
const visibleModel = ref(false);
/**
 * 根据关键字获取品牌
 */
const requirBrand = async (e: String) => {
  const a = await RequestCarBrand(e);
  brandList.value = JSON.parse(
    JSON.stringify(a.resultObj)
      .replaceAll("firstLetter", "letter")
      .replaceAll("brands", "data")
  );
};
const handleClick = () => {
  visible.value = false;
  visibleSerise.value = false;
  visibleModel.value = false;

  requirBrand("");
};
/**
 * 点击品牌输入框
 */
const brandSelect = () => {
  visible.value = true;
  visibleSerise.value = false;
  visibleModel.value = false;
};
/**
 * 点击车系输入框
 */
const SeriesSelect = () => {
  visibleSerise.value = true;
  visible.value = false;
  visibleModel.value = false;
};
/**
 * 点击车型输入框
 */
const modelSelect = () => {
  visibleModel.value = true;
  visible.value = false;
  visibleSerise.value = false;
};
const wortList = ref([
  "A",
  "B",
  "C",
  "D",
  "E",
  "F",
  "G",
  "H",
  "I",
  "J",
  "K",
  "L",
  "M",
  "N",
  "O",
  "P",
  "Q",
  "R",
  "S",
  "T",
  "U",
  "V",
  "W",
  "X",
  "Y",
  "Z",
]);
const onScroll = (e: any) => {
  let scrollItems = document.querySelectorAll(".itemTit");
  for (let i = scrollItems.length - 1; i >= 0; i--) {
    // 判断滚动条滚动距离是否大于当前滚动项可滚动距离
    let judge =
      e.target.scrollTop >= scrollItems[i].offsetTop - scrollItems[0].offsetTop;
    if (judge) {
      activeStep.value = i;
      break;
    }
  }
};
const jump = (index: number) => {
  let target = document.querySelector(".city_menu_container");
  let scrollItems = document.querySelectorAll(".area");
  // 判断滚动条是否滚动到底部
  if (target!.scrollHeight <= target!.scrollTop + target!.clientHeight) {
    activeStep.value = index;
  }
  let roll = scrollItems[index].offsetTop - scrollItems[0].offsetTop; // 锚点元素距离其滚动窗口顶部的距离(待滚动的距离)
  let distance = document.querySelector(".city_menu_container")!.scrollTop; // 滚动条距离滚动区域顶部的距离
  // 滚动条距离滚动区域顶部的距离(滚动区域为窗口)
  // 滚动动画实现, 使用setTimeout的递归实现平滑滚动，将距离细分为10小段，10ms滚动一次
  // 计算每一小段的距离
  let step = roll / 10;
  if (roll > distance) {
    rollDown(target);
  } else {
    let newTotal = distance - roll;
    step = newTotal / 10;
    rollUp(target);
  }
  // node为滚动区域节点
  function rollDown(node: any) {
    if (distance < roll) {
      distance += step;
      node.scrollTop = distance;
      setTimeout(rollDown.bind(this, node), 10);
    } else {
      node.scrollTop = roll;
    }
  }
  // node为滚动区域节点
  function rollUp(node: any) {
    if (distance > roll) {
      distance -= step;
      node.scrollTop = distance;
      setTimeout(rollUp.bind(this, node), 10);
    } else {
      node.scrollTop = roll;
    }
  }
};
// 点击品牌列表
const chose = (e: any, index: number, newIndex: number) => {
  brandIndex.value = newIndex;
  wortIndex.value = index;
  // this.$emit('closeList', e)
  AddProductFormData.value.brand = e;
  AddProductFormData.value.series = "";
  AddProductFormData.value.modelName = "";
  AddProductFormData.value.modelId = null;
  closeList(e);
  brandClick(e);
};
const closeList = (val: any) => {
  inpVal.value = val;
  visible.value = false;
};
/**
 * 选择品牌，获取车系
 */
const brandClick = async (e: any) => {
  const a = await RequestCarType(e, "");
  // console.log(AddProductFormData.value);
  if (a.msg == "操作成功！") {
    carType.value = a.resultObj;
  }
};
/**
 * 根据关键字匹配品牌
 */
let time = ref();
const searchBrand = () => {
  if (time != null) {
    clearTimeout(time.value);
  }
  time.value = setTimeout(() => {
    requirBrand(AddProductFormData.value.brand);
  }, 500);
};
const searchSerise = () => {
  if (time != null) {
    clearTimeout(time.value);
  }
  time.value = setTimeout(async () => {
    const a = await RequestCarType(
      AddProductFormData.value.brand,
      AddProductFormData.value.series
    );
    console.log(AddProductFormData.value);

    if (a.msg == "操作成功！") {
      carType.value = a.resultObj;
    }
  }, 500);
};
const searchModel = () => {
  if (time != null) {
    clearTimeout(time.value);
  }
  time.value = setTimeout(async () => {
    const a = await RequestCarSeries(
      AddProductFormData.value.series,
      AddProductFormData.value.modelName
    );
    console.log(AddProductFormData.value);

    if (a.msg == "操作成功！") {
      carSeriesList.value = a.resultObj;
    }
  }, 500);
};

// 选择车系
const carTypeSelect = async (item: any) => {
  AddProductFormData.value.series = item.seriesName;
  AddProductFormData.value.modelName = "";
  AddProductFormData.value.modelId = null;
  const a = await RequestCarSeries(item.seriesName, "");
  if (a.msg == "操作成功！") {
    carSeriesList.value = a.resultObj;
  }
};
const ModelTypeSelect = (item: any) => {
  console.log(item);
  AddProductFormData.value.modelName = item.modelName;
  AddProductFormData.value.model = item.id;
};

// 溯源件导出
const exportExcelFitting = () => {
  let nowDate = formatTimeHan(new Date());
  RequestFittingsOutputExcel({
    page: 1,
    rows: 100000,
  }).then((res: any) => {
    if (res.type == 'application/json') {
      ElMessage.error('暂无数据导出')
    } else {
      exportFile(res, `${nowDate}所有溯源件数据报表`);
    }
  });
};
// 非溯源件导出
const exportExcelParts = () => {
  let nowDate = formatTimeHan(new Date());
  RequestPartsStatisticOutputExcel({
    page: 1,
    rows: 100000,
  }).then((res: any) => {
    if (res.type == 'application/json') {
      ElMessage.error('暂无数据导出')
    } else {
      exportFile(res, `${nowDate}所有非溯源件数据报表`);
    }
  });
};
</script>

<style scoped lang="scss">
.main {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .top {
    width: 100%;
    background-color: #fff;
  }

  .content {
    width: 100%;
    background-color: #fff;
  }
}

.icon_i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6.875rem;
  right: 0;
  margin: auto 0;
}

.downLoad {
  line-height: 1rem;
  margin-left: 0.625rem;
  color: #116cf8;
}

.el-select {
  width: 100%;
}

.el-input-number {
  width: 100%;
}

.drawer_top {
  width: 100%;
  background-color: #fff;
  border-radius: 0.5rem;
}

/* 弹出框样式 */
::v-deep .el-overlay {
  .el-dialog__header {
    background-color: #116cf8;
    margin-right: 0;
  }

  .el-dialog__title {
    color: #fff;
  }

  .el-drawer {
    .el-form {
      .el-icon svg {
        color: #dcdfe6;
      }
    }
  }
}

::v-deep .el-drawer {
  .el-overlay .el-icon svg {
    color: #fff;
  }

  .el-drawer__header {
    margin-bottom: 0;
  }
}

::v-deep .b0 {
  .el-input__wrapper:nth-child(1) {
    border-radius: 0.25rem 0rem 0rem 0.25rem;
    position: relative;
    left: 0.0625rem;
  }

  .el-input__wrapper:nth-child(2) {
    border-radius: 0rem 0.25rem 0.25rem 0rem;
  }
}

.DocumentNumber {
  .el-button {
    background-color: #fff;
    border: 0.0625rem solid #dcdfe6;
    border-left: none;
  }
}

.drawer_bottom {
  width: 100%;
  height: 10%;
  background-color: #fff;
  padding: 1.25rem;
  position: absolute;
  bottom: 0;
  right: 0;
}

.menu {
  width: 13.75rem;
  height: 18.75rem;
  display: flex;
  flex-wrap: wrap;
  position: relative;

  .city_menu_container {
    width: 100%;
    height: 100%;
    overflow-y: scroll;

    .item {
      width: 80%;
      word-break: break-all;
      margin: 1.25rem 0;
    }
  }

  .city_list_container {
    width: 12%;
    height: 96%;
    position: absolute;
    right: 1.25rem;
    overflow-y: scroll;
    // scrollbar-width: thin;
    // scrollbar-color: transparent transparent;
  }

  .city_list_container::-webkit-scrollbar {
    width: 0.375rem;
  }

  .city_list_container::-webkit-scrollbar-thumb {
    background-color: transparent;
  }

  .city_list_container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
  }
}

.city_menu_container::-webkit-scrollbar {
  display: none !important;
}
</style>
